Download the PHP package railken/lem without Composer
On this page you can find all versions of the php package railken/lem. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package lem
Lem
A precise way to structure your logic to improve readability and maintainability of your code when building API.
Requirements
PHP 8.1 and later.
Installation
You can install it via Composer by typing the following command:
The package will automatically register itself.
Usage
First you need to generate a new structure folder, use:
php artisan railken:make:manager app App\Foo
.
Now you can use it.
How can you get an Error during an operation? An error occurs when a validation or authorization fails. The cool thing about it is that you have the total control during each process: using Authorizer. When you're retrieving errors you're receiving a Collection, it goes pretty well when you're developing an api. Here's an example
So, what about the authorization part? First we have to edit the class User.
You can set the method can as you wish, it's better if a permission library is used such as https://github.com/Zizaco/entrust or https://github.com/spatie/laravel-permission.
If no system permission is needed simply leave return true.
"foo.attributes.title.fill" is passed to User::can() and if the return is false the result will contains errors.
Note: if you don't set any agent, the SystemAgent will be used (all granted).
See Authorizer for more explanations.
Commands
- Generate a new set of files
php artisan railken:make:manager [path] [namespace]
. E.g. php artisan railken:make:manager App "App\Foo"
Manager
This is the main class, all the operations are performed using this: creating, updating, deleting, retrieving. This class is composed of components which are: validator, repository, authorizer, parameters, serializer
See Manager.
Model
This is the Eloquent Model, nothing changes, excepts for an interface
Repository
This is a Repository, the concept is very similar to the Repository of Symfony, code all your queries here.
See Repository for more information.
Validator
Here comes the validator, and again it's very simple. validate() is called whenever a create/update operation is called. Remember: always return the collection of errors. You can of course add a specific library for validation and use it here.
Serializer
This class will serialize your model
All versions of lem with dependencies
railken/bag Version ^2.0.0
respect/validation Version ^2.2
nikic/php-parser Version ^4.18
symfony/yaml Version 6.* || 7.*
symfony/validator Version 6.* || 7.*
ext-intl Version *