Download the PHP package mach/silex-rest without Composer

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

RestApplicationServiceProvider

Build Status

RestApplicationServiceProvider for Silex gives developers ability to rapidly create REST applications.

Few words about the conversions are needed. This provider gives you a service to build RESTful routes faster and more consistently across the whole application. While you can create , , , , and actions, not all can be used with individual items or collections. The endpoint should be defined as a plural name of the item type, e.g. (but you are not limited by the provider and can use whatever convention you like).

Unfortunately there is no option to automatically create custom route for action, e.g. , but you can still do it manually by adding such route to .

The library requires you to have enabled because I recommend you to use a class for a resource's controller. This way you can keep your application well-organized and reuse the controllers in Symfony2, for instance. And if you decide to keep your controllers with Silex only, you can use which implements to fastly throw 404 in case of your will to hide some actions from users, and delegates method calls to (passed by constructor) if needed.

Installation w/ Composer

  1. Add requirement using CLI: .
  2. Update the requirement .

Alternatively you can add the requirement manually:

Usage

Registering the provider

There is also a trait available for more cleaner usage.

Basic usage

Registering resource

Creating collection actions

Creating item actions

Adding converter

You can use converters with item actions. This can help you convert between to the whole entity for example.

Adding constraint check to item ID

To check if the provided ID is e.g. an integer, you can add global resource assertion, just like in regular Silex route.

Adding and middlewares

Middlewares are action-specific and you can't (sorry) define a global middleware for all actions.

Controller class usage

You can use an existing service controller or register one automatically when passing an object to .

Using existing controller service

Your class should define , , , , , and methods. Later I will show you how to change method names across the application.

Creating controller service on fly

What more can you do with RestApplicationServiceProvider?

Subresources

You can use subroutes for pairing resources together. For example, if you have a relation between Users and Notes (one-to-many) and use user friendly URLs (), you can create a subresource.

The variable to which note ID will be bound to will be . If you create a subresource to the next ID will be (see the convention?). But you can change it. Simply, pass the name as third parameter of subresource:

Overriding default method names for controller classes

While registering the provider, pass variables to the container.

You can also change a chosen method on-fly between and calls. To change item method, call which will affect further (sub)resource creations.

License

RestApplicationServiceProvider is licensed under the MIT license.


All versions of silex-rest with dependencies

PHP Build Version
Package Version
Requires silex/silex Version ~2.0@dev
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 mach/silex-rest contains the following files

Loading the files please wait ....