Laravel Api

screenshot of Laravel Api

Laravel Api

A simplest DDD boilerplate for your Laravel Api project


The Laravel ApiCircleCI is a modern and elegant Laravel boilerplate designed for building APIs. It follows the principles of Domain Driven Design and hexagonal architecture, making it a powerful tool for developing robust and scalable applications. With features like API authentication using JWT, ACL and Laravel Policies for access control, and comprehensive API documentation generation, Laravel ApiCircleCI provides a solid foundation for creating highly functional APIs.


  • PHP 8.1+: The boilerplate is built with the latest version of PHP, ensuring compatibility and the use of the most up-to-date features.
  • Laravel 9: Based on Laravel 9, ApiCircleCI leverages the power and flexibility of this popular PHP framework.
  • Github Docs: The documentation for the boilerplate is hosted on Github, making it easy to access and contribute to.
  • CircleCI Site: ApiCircleCI provides integration with CircleCI, a continuous integration and delivery platform, allowing for automated testing and deployment.
  • API Restful: The boilerplate follows RESTful principles, providing a standardized and intuitive API design.
  • JWT Auth: ApiCircleCI supports JWT (JSON Web Tokens) authentication, ensuring secure and stateless authentication for API requests.
  • ACL & Laravel Policies: Access Control Lists (ACL) and Laravel Policies are implemented, allowing for fine-grained control over user permissions and authorization.
  • PestPHP Tests: The boilerplate includes tests written using PestPHP, a testing framework that focuses on simplicity and readability.
  • OpenApi Docs: ApiCircleCI generates comprehensive API documentation using OpenApi, making it easy for developers to understand and integrate with the API.


To install Laravel ApiCircleCI, follow these steps:

  1. Create your project using Composer:

    composer create-project your-project-name
  2. Set up the necessary directories. The directory structure is as follows:

    • Factories
    • Routes
  3. Configure the API routes. Below are some examples of the available routes:

    • GET /api-docs: Get the API documentation.
    • POST /auth/login: Sign in.
    • POST /auth/logout: Sign out.
    • POST /auth/refresh: Refresh the JWT Token.
    • GET /auth/me: Get authenticated user's profile.
    • PUT /auth/me: Edit authenticated user's profile.
    • PUT /auth/me/password: Change authenticated user's password.
    • GET /permissions: Get the permission list.
    • GET /roles: Get the role list.
    • GET /roles/{uuid}: Get the role.
    • POST /roles: Create a new role.
    • PUT /roles/{uuid}: Edit the role.
    • DELETE /roles/{uuid}: Delete the role.
    • GET /users: Get the user list.
    • GET /users/{uuid}: Get the user.
    • POST /users: Create a new user.
    • PUT /users/{uuid}: Edit the user.
    • DELETE /users/{uuid}: Delete the user.
  4. Generate the API documentation using the provided PHP libraries.

  5. Optional: Install additional PHP libraries for enhanced functionality. Some recommended libraries include Laracasts Presenter, Clockwork, Spatie Data Transfer Objects, Spatie Laravel Fractal, Spatie Laravel Query Builder, Spatie Permissions, Darka On Line Swagger, FriendsOfPHP CS Fixer, Laravel IDE Helper, Larastan, PestPHP, and Enlightn Security Checker.

  6. Use Composer scripts for convenient commands such as clearing Laravel cache, optimizing the API, fixing coding style, running static analysis, running tests, checking PHP library security, and generating documentation.

    composer clear - Clear Laravel cache
    composer optimize - Optimize API
    composer cs - Fix coding style
    composer analyse - Run Larastan static analysis
    composer test - Run PestPHP tests
    composer sec - Check PHP libraries security
    composer code - Run cleaning, analysis, tests, and security checks
    composer doc - Generate API documentation


In summary, Laravel ApiCircleCI is a powerful boilerplate for building APIs with Laravel. It incorporates modern development principles, such as Domain Driven Design and hexagonal architecture, and provides essential features like JWT authentication, ACL and Laravel Policies for access control, and comprehensive API documentation generation. With easy installation and integration with popular PHP libraries and tools, Laravel ApiCircleCI offers developers a solid foundation for creating robust and scalable API applications.


PostCSS is a popular open-source tool that enables web developers to transform CSS styles with JavaScript plugins. It allows for efficient processing of CSS styles, from applying vendor prefixes to improving browser compatibility, ultimately resulting in cleaner, faster, and more maintainable code.