Download the PHP package juliomotol/lapiv without Composer

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

Lapiv

Latest Version on Packagist Total Downloads

This package is feature locked

With the recent developments in PHP, Laravel and its community of packages, it has been easier than ever to manage routes for versioned APIs.

We have found better ways to do what this package does in a much cleaner way. We suggest for you to take a look at spatie/laravel-route-attributes or spatie/laravel-route-discovery.

With that, we will still continue to provide support for future PHP/Laravel updates until any major breakage.

A Small Laravel package for a simple and easy API versioning.

Lapiv simply stands for (L)aravel (API) (V)ersioning.

Installation

You can install the package via composer:

Config

Key Default Value Description
default "uri" The versioning method. Supports: "uri", "query_string".
methods.uri.prefix "v{version}" The prefix for uri based versioning. (NOTE: Always include the "version" parameter in the prefix)
methods.query_string.key "v" The query string key name for determining the version

If you want to make changes in the configuration you can publish the config file using:

Setup

Now the juicy part, we'll walk you through how to setup versioned Controllers.

FooV1Controller.php

This is very much like your standard controller. Nothing special here really. All action methods must be declared here e.g. index, create, show, etc.

FooGatewayController.php

Now the good stuff. This controller MUST extend \JulioMotol\Lapiv\GatewayController in order for this whole thing to work. This will be in charge of dispatching the requests based on the requested version. Let's take a look inside.

The order in $apiControllers is critical. The first controller declared will be our v1, then will be v2, and so on.

Routing

With our controllers ready to go, lets create our route. Go to routes/api.php.

Notice we didn't point to the [FooV1Controller::class, 'index']. As we've said, the FooGatewayController will be doing much of the heavy work, so we'll just call that instead.

When you run php artisan route:list you should see this.

Method URI Action
GET|HEAD api/v{version}/foo App\Http\Controllers\Api\FooGatewayController@index
GET|HEAD api/v{version}/bar App\Http\Controllers\Api\BarGatewayController@index

Now, when we try to go to /api/v1/foo, it should be handled by FooV1Controller.

Bumping a version

When your ready to bump your API version to v2, Simply add a new FooV2Controller and dont forget to add that to FooGatewayController's $apiControllers.

Versioning Methods

This package supports 2 types of API Versioning methods, uri and query_string.

uri Method

This is the default of the versioning method. Here, the API version will be declared in the uri path (e.g. example.com/api/v1/foo).

In the config, you can change the prefix for the uri.

Don't forget to add the version parameter in the prefix.

query_string Method

Here, the API version will be declared in the query string (e.g. example.com/api/foo?v=1).

In the config, you can change the query string key.

Want to handle your own versioning method?

You can define how you want to handle versioning your APIs by extending JulioMotol\Lapiv\Drivers\BaseDriver:

You can also handle routing by overriding the routeGroup() method in the BaseDriver.

Then add your new API driver in your AppServiceProvider::boot():

And finally, use your new driver in the config/lapiv.php

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of lapiv with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0
illuminate/routing Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.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 juliomotol/lapiv contains the following files

Loading the files please wait ....