Download the PHP package ingruz/yodo without Composer

On this page you can find all versions of the php package ingruz/yodo. 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 yodo

Yodo

Latest Version on Packagist Total Downloads

A set of utility to easily and rapidly create REST api with Laravel.

Requirements

Yodo requires php 7.0 or above and is designed to work with Laravel 5.5 or above.

Install

Via Composer

Getting started

Suppose you need to create CRUD (or, more precisely, BREAD) handlers for a Post model, you should first create a PostController class inside your app/Http/Controllers folder.

Then you should tell your router to use that controller for handling the Post resource:

And that's it! You now should have a full working BREAD endpoint for the Post resource, with enabled support for pagination, filtering, sorting and more!

Usage

Of course you can customize most of Yodo's behaviour!

In addition to Controllers there are two other main pieces of Yodo that are Repositories and Transformers. By default Yodo will search for a custom Repository in app/Repositories folder, and for a custom Transformer in app/Transformers (in future both paths will be customizable), searching with the name of the controller's resource (for example if the class name is PostController it will search for PostRepository and PostTransformer respectively).

You can always specify them with a custom path or name overriding protected getRepositoryClass or getTransformerClass methods in your controller.

If you don't specify anything and Yodo can't find a suitable class, it will fall back to default Repository and Trasformer. In most cases you won't need to customize the Repositories but this will happen more ofter for the Transformers, since the default one will just return the model as an array.

Repository

To create a custom repository, just extend the default one:

Like the Controller, by default the Repository will search for it's model class in your root name space (so PostRepository will look for App\Post model). You can always specify by overriding the getModelClass method or by passing direcly an instance to the Repository's constructor (also passing the classname as string is supported).

It's possible to customize in many way how a Repository works, expecially when handling the getAll method that it's used by the index method inside the resource Controller:

Handle query's params

Query parameters defined here will be automatically handled by the repository, you can define them as an hash in $queryParamsHandlers or by returning an array overriding the method getQueryParams:

So the values of the hash could be:

Request validation

It is possible to specify an array of Laravel's validation rules that will be used by the repository to validate the requests before creating and updating actions.

You can define the rules as a plain array:

Or just define rules for a specific action:

Or define general rules that should always be checked and rules specific to an action:

Events

A great place where setting up model's events is the boot method of the repository:

Public API

Transformer

Yodo uses the excellent Fractal library for handling the transformation of Models in json.

To create a custom Transformer just extends Fractal's TransformerAbstract:

Exceptions

Yodo will automatically returns error responses following two exceptions:

Customization

To customize some default aspects of Yodo you will need to use its service provider. If you are on Laravel 5.5 or above you don't have to do anything, Package Discovery will include it for you.

Otherwise just add it to your config/app.php file providers's array:

The you can publish the yodo.php config file with the command php artisan vendor:publish.

Inside you can customize Repositories and Transformers namespace roots and which http error code Yodo will return in case of ModelValidationException and ApiLimitNotValidException.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

Contributing

Please see CONDUCT for details.

Security

If you discover any security related issues, please email direcly the author instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of yodo with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3 || >=8.0
illuminate/support Version ^8.0
league/fractal Version ^0.19.0
spatie/fractalistic Version ^2.9
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 ingruz/yodo contains the following files

Loading the files please wait ....