Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pd Api Laravel Package

appaydin/pd-api

View on GitHub
Deep Wiki
Context7

pdApi Bundle

Symfony 5 Restful Api Bundle

Packagist Github Release license PHP from Packagist

  • Supports XML and JSON response
  • Error messages are collected under a single format.
  • Language translation is applied to all error messages.
  • Request body Transformer (JSON-XML) has been added.
  • Normalizer has been added for form errors.
  • Normalizer has been added for KnpPaginator.

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

composer require appaydin/pd-api

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

With Symfony 5, the package will be activated automatically. But if something goes wrong, you can install it manually.

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

<?php
// config/bundles.php

return [
    //...
    Pd\ApiBundle\PdApiBundle::class => ['all' => true]
];

Step 3: Settings Bundle

# config/packages/pd_api.yaml

pd_api:
    zone: ["^/api"]
    default_accept: json
    default_groups: ['default']
    allow_accept: ['json', 'xml']

Step 4: Settings Security.yaml

# config/packages/security.yaml

security:
  providers:
    ...
    pdadmin_api:
      entity:
        class: App\Entity\User
        property: phone
  firewalls:
    ...
    api:
      pattern: ^/api
      stateless: true
      anonymous: true
      provider: pdadmin_api
      json_login:
        check_path: /api/auth/login
        failure_handler: lexik_jwt_authentication.handler.authentication_failure
      guard:
        authenticators:
          - lexik_jwt_authentication.jwt_token_authenticator
  access_control:
    - { path: ^/api/auth, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }

Step 5 (Optional): Create Login Endpoint

# src/Controller/AuthorizationController.php

namespace App\Controller;

use Pd\ApiBundle\Controller\AbstractApiController;
use Pd\ApiBundle\Controller\LoginTrait;

class AuthorizationController extends AbstractApiController
{
    use LoginTrait;
}
# config/routes.yaml
api:
  resource: ../src/Controller
  type: annotation
  prefix: api

Create API

# src/Controller/ExampleApiController.php

use Pd\ApiBundle\Controller\AbstractApiController;
use Symfony\Component\Routing\Annotation\Route;

class ExampleApiController extends AbstractApiController
{
    #[Route("/home", name:"api.home", methods: ["GET"])]
    public function home() {
        return ['test'];
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky