Download the PHP package w2w/laravel-apie without Composer
On this page you can find all versions of the php package w2w/laravel-apie. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download w2w/laravel-apie
More information about w2w/laravel-apie
Files in w2w/laravel-apie
Package laravel-apie
Short Description Laravel wrapper for w2w/apie
License GPL-3.0-or-later
Informations about the package laravel-apie
laravel-apie
Laravel wrapper for the apie library
What does it do
This is a small wrapper around the library w2w/apie for Laravel. This library maps simple POPO's (Plain Old PHP Objects) to REST api calls. It is very similar to the excellent api platform library, but then for Laravel.
It also adds a class EloquentModelDataLayer to persist and retrieve api resources as Eloquent models and adds a status check to see if it can connect with the database. See the documentation of apie at https://github.com/pjordaan/apie
Forwards compatiblity Apie version 4
By default laravel-apie will still use the old 3. serialization. In Apie version 4 this will change drastically, so a config option is added to enable the forwards compatible 4. release.
Contents
- Installation
- Lumen integration
- Adding a a new api resource
- Automate registering classes
- Hooking in the laravel/lumen error handler
- Optimizations for production
- Versioning
- Integrate Eloquent with Apie
- Custom normalizers/value objects
- Modifying OpenAPI spec
- Use your own controllers
- Resource sub actions
- Laravel components integration
- PSR6 Cache integration
- L5-swagger integration
- Localization aware API
Installation
In your Laravel package you should do the usual steps to install a Laravel package.
In case you have no autodiscovery on to add W2w\Laravel\Apie\Providers\ApiResourceServiceProvider::class to your list of service providers manually.
Afterwards run the commands to publish the config to apie.php and run the migrations for the status checks.
Now visit /swagger-ui to see the generated OpenApi spec. It will only contain specs for the default installed api resources, which is a check to identify your REST API and a health check resource. It will check if it can connect to the database.
Adding a new api resource
create this class in your app/ApiResources:
Now in config/apie.php we should add the class to add it to the api resources:
If you refresh /api/doc.json you can see you get an extra POST call to create a SumExample resource. With any OpenApi tool or with Postman you can test the POST command. If you would make a POST call to /api/sum_example with body
You would get:
Automate registering api resources.
It is possible to automate registering api resources without having to manually update the resources list in config/apie.php We can auto-register all classes in a specific namespace with this:
-
In a terminal run:
- Open config/apie.php
- Edit the file like this:
Now if I put a class inside the namespace App\RestApi\ApiResources, the class will be registered for Apie.
Make sure that for production you use laravel's config cache to reduce load on your server.
All versions of laravel-apie with dependencies
doctrine/annotations Version ^1.7
doctrine/cache Version ^1.8
illuminate/container Version ^5.6|^6.0|^7.0
illuminate/contracts Version ^5.6|^6.0|^7.0
illuminate/database Version ^5.6|^6.0|^7.0
illuminate/http Version ^5.6|^6.0|^7.0
illuminate/routing Version ^5.6|^6.0|^7.0
ramsey/uuid Version ^3.8
symfony/cache Version ^4.4|^5.0
symfony/options-resolver Version ^4.4|^5.0
symfony/psr-http-message-bridge Version ^1.2
symfony/serializer Version ^4.4|^5.0
w2w/apie Version ^3.4.2