Download the PHP package phpguild/api-bundle without Composer

On this page you can find all versions of the php package phpguild/api-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package api-bundle

Symfony API Bundle

Features

Authentication

Filters

Installation

Install with composer

composer req phpguild/api-bundle

Configure API Platform

Edit config/packages/api_platform.yaml

api_platform:
    version: '1.0.0'
    mapping:
        paths: [ '%kernel.project_dir%/src/Entity' ]
    patch_formats:
        json: [ 'application/merge-patch+json' ]
    formats:
        jsonld:
            mime_types: [ 'application/ld+json' ]
        json:
            mime_types: [ 'application/json' ]
        html:
            mime_types: [ 'text/html' ]
    error_formats:
        jsonld:
            mime_types: [ 'application/ld+json' ]
        json:
            mime_types: [ 'application/json' ]
    swagger:
        versions: [ 3 ]
        api_keys:
            apiKey:
                name: Authorization
                type: header
    defaults:
        pagination_enabled: true
        pagination_items_per_page: 10
        pagination_maximum_items_per_page: 30
        pagination_client_partial: true
        pagination_client_items_per_page: true
    collection:
        exists_parameter_name: _exists
        order_parameter_name: _order
        pagination:
            page_parameter_name: _page
            items_per_page_parameter_name: _itemsPerPage
            partial_parameter_name: _partial

Configure User authentication with JWT

Edit config/packages/security.yaml

security:

    encoders:
        App\Entity\User:
            algorithm: auto

    providers:
        authentication_user_provider:
            entity:
                class: App\Entity\User
                property: username

        token_user_provider:
            entity:
                class: App\Entity\User
                property: id

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        oauth_refresh_token:
            pattern:  ^/oauth/refresh_token
            stateless: true
            anonymous: true

        oauth_authenticate:
            pattern:  ^/oauth/authenticate
            stateless: true
            anonymous: true
            user_checker: PhpGuild\UserBundle\Security\UserChecker
            json_login:
                provider: authentication_user_provider
                check_path: api_users_authentication
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure

        api:
            pattern:  ^/
            stateless: true
            anonymous: true
            provider: token_user_provider
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator

        main:
            anonymous: true
            lazy: true

access_control:
    - { path: ^/oauth/authenticate, methods: [ POST ], roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/oauth/refresh_token, methods: [ POST ], roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api/docs, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }

Edit config/packages/lexik_jwt_authentication.yaml

lexik_jwt_authentication:
    secret_key: '%env(resolve:JWT_SECRET_KEY)%'
    public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
    pass_phrase: '%env(JWT_PASSPHRASE)%'
    token_ttl: 3600
    user_identity_field: id
    token_extractors:
        authorization_header:
            enabled: true
            prefix:  Bearer
            name:    Authorization

Edit config/routes.yaml

phpguild_api_oauth:
    resource: '@PhpGuildApiBundle/Resources/config/routes/oauth.yaml'
    prefix: /oauth

Configure refresh Token

gesdinet_jwt_refresh_token:
    firewall: api
    ttl: 2592000
    ttl_update: true
    user_identity_field: id
    user_provider: security.user.provider.concrete.token_user_provider

Multisearch filter

Usage

use PhpGuild\ApiBundle\Doctrine\Orm\Filter\MultisearchFilter;

/**
 * @ApiResource
 * @ApiFilter(MultisearchFilter::class, properties={"name", "description", "postalcode":"exact", "categories.name"})
 */
class MyEntity
{
    private string $name;
    private string $description;
    private string $postalcode;
    private Collection $categories;

GeoDistance filter

Configuration

Edit config/packages/doctrine.yaml

doctrine:
    orm:
        dql:
            numeric_functions:
                acos: DoctrineExtensions\Query\Mysql\Acos
                cos: DoctrineExtensions\Query\Mysql\Cos
                radians: DoctrineExtensions\Query\Mysql\Radians
                sin: DoctrineExtensions\Query\Mysql\Sin

Usage

use PhpGuild\ApiBundle\Doctrine\Orm\Filter\GeoDistanceFilter;

/*
 * @ApiResource
 * @ApiFilter(GeoDistanceFilter::class, attributes={"latPropertyName":"lat", "lngPropertyName":"lng"})
 */
class MyEntity
{
    private float $lat;
    private float $lng;

All versions of api-bundle with dependencies

PHP Build Version
Package Version
Requires ext-json Version *
php Version >=7.2
api-platform/api-pack Version 1.3.*
gesdinet/jwt-refresh-token-bundle Version ^0.10.1
lexik/jwt-authentication-bundle Version 2.11.*
phpguild/user-bundle Version 1.0.*
symfony/string Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phpguild/api-bundle contains the following files

Loading the files please wait ....