Download the PHP package rupadana/filament-api-service without Composer

On this page you can find all versions of the php package rupadana/filament-api-service. 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 filament-api-service

Filament Api Service

Total Downloads Run Test

Filament API Service is a powerful yet simple package that enables automatic API generation for FilamentPHP resources. It eliminates the need for manual route registration and provides built-in support for authentication, authorization, filtering, sorting, and more.

Features

Installation

Install the package via Composer:

Register it in your Filament Provider:

For further configuration, run:

Usage

Create an API service for a Filament resource:

Since version 3.0, routes automatically registered. it will grouped as '/api/admin'. admin is panelId. to disable panelId prefix, please set route.panel_prefix to false

Once generated, the following API endpoints are automatically available:

Method Endpoint Description
GET /api/admin/blogs Return LengthAwarePaginator
GET /api/admin/blogs/1 Return single resource
PUT /api/admin/blogs/1 Update resource
POST /api/admin/blogs Create resource
DELETE /api/admin/blogs/1 Delete resource

To disable the admin panel prefix, update the config:

Token Resource

By default, Token resource only show on super_admin role. you can modify give permission to other permission too.

Token Resource is protected by TokenPolicy. You can disable it by publishing the config and change this line.

[!IMPORTANT]
If you use Laravel 11, don't forget to run to publish the personal_access_tokens migration after that run to migrate the migration, but as default if you run the it will ask you to migrate your migration.

Filtering & Allowed Field

We used "spatie/laravel-query-builder": "^5.3" to handle query selecting, sorting and filtering. Check out the spatie/laravel-query-builder documentation for more information.

In order to allow modifying the query for your model you can implement the HasAllowedFields, HasAllowedSorts and HasAllowedFilters Contracts in your model.

Create a Handler

To create a handler you can use this command. We have 5 Handler, CreateHandler, UpdateHandler, DeleteHandler, DetailHandler, PaginationHandler, If you want a custom handler then write what handler you want.

or

Transform API Response

it will be create BlogTransformer in App\Filament\Resources\BlogResource\Api\Transformers

next step you need to edit & add it to your Resource

Group Name & Prefix

You can edit prefix & group route name as you want, default this plugin use model singular label;

Middlewares

You can add or override middlewares at two specific places. Via the Filament Panel Provider and/or via the Resources $routeMiddleware.

If you set route.use_resource_middlewares to true, the package will register the middlewares for that specific resource as defined in:

Then your API resource endpoint will go through these middlewares first.

Another method of adding/overriding middlewares is via the initialization of the plugin in your Panel Provider by adding the middleware() method like so:

Tenancy

When you want to enable Tenancy on this package you can enable this by setting the config tenancy.enabled to true. This makes sure that your api responses only retreive the data which that user has access to. So if you have configured 5 tenants and an user has access to 2 tenants. Then, enabling this feature will return only the data of those 2 tenants.

If you have enabled tenancy on this package but on a specific Resource you have defined protected static bool $isScopedToTenant = false;, then the API will honour this for that specific resource and will return all records.

If you want to make api routes tenant aware. you can set tenancy.awareness to true in your published api-service.php. This way this package will register extra API routes which will return only the specific tenant data in the API response.

Now your API endpoints will have URI prefix of {tenant} in the API routes when tenancy.awareness is true.

It will look like this:

Overriding tenancy ownership relationship name by adding this property to the Handlers protected static ?string $tenantOwnershipRelationshipName = null;

How to secure it?

Since version 3.4, this plugin includes built-in authentication routes:

Method Endpoint Description
POST /api/auth/login Login
POST /api/auth/logout Logout

We also use the permission middleware from spatie/laravel-permission. making it easier to integrate with filament-shield

If you prefer to use the old version of the middleware, please set 'use-spatie-permission-middleware' => false.

Public API

Set API to public by overriding this property on your API Handler. Assume we have a PaginationHandler

API Documentation

For our documentation, we utilize Scramble, a powerful tool for generating and managing API documentation. All available routes and their detailed descriptions can be accessed at /docs/api. This ensures that developers have a centralized and well-organized resource to understand and integrate with the API effectively.

License

The MIT License (MIT).

Supported By


All versions of filament-api-service with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
dedoc/scramble Version ^0.12.10
filament/filament Version ^3.2
illuminate/contracts Version ^10.0|^11.0|^12.0
laravel/framework Version ^10.10|^11.0|^12.0
laravel/sanctum Version ^3.2|^4.0
spatie/laravel-package-tools Version ^1.19
spatie/laravel-query-builder Version ^5.3|^6.3
spatie/laravel-permission Version ^6.0
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 rupadana/filament-api-service contains the following files

Loading the files please wait ....