Download the PHP package rougin/dexter without Composer

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

Dexter

Latest Version on Packagist Software License Build Status Coverage Status Total Downloads

Dexter is a utility PHP package that provides extensible PHP classes for handling CRUD operations. It can also create HTTP routes that conforms to the PSR-07 standard.

Installation

Install the Dexter package via Composer:

Using Depot

The Depot class is a special PHP class which provides methods related to CRUD operations (e.g., create, delete, find, update):

Using the Depot class improves development productivity as it reduces writing of code relating to CRUD operations. As it is also designed to be extensible, it can be used freely without the required methods.

[!NOTE] In other PHP frameworks and other guides, Depot is also known as Repository from the Repository pattern.

If a Depot class is used, the following methods must be defined depending on its usage:

create method

The create method will be used for creating an item based on the provided payload:

If the specified method is being called, its logic must be defined from the Depot class:

If the required logic for the create method is not defined, it will throw a LogicError.

delete method

When deleting specified items, the delete method can be used from the Depot class:

Using the delete method also requires other methods deleteRow and rowExists to be defined:

If the required logic for the delete method is not defined, a LogicError will be thrown.

find method

The find method is one of the CRUD operations that tries to find an item based on the given unique identifier (e.g., id):

To use the find method, kindly write its logic in the findRow method:

If the specified identifier does not exists, it must throw an UnexpectedValueException. Likewise, if the required logic for the find method is not defined, it will throw a LogicError.

get method

One of the methods of Depot that returns an array of items based on the specified page number and its rows to be shown per page:

To use the get method, the methods getItems and getTotal must be defined:

If the logic requires an offset instead of a page number, the getOffset method from Depot can be used to compute the said offset value:

Using the get method returns a Result class, which can be used for handling the result from the Depot:

Each item from the Result class can also be parsed manually using the asRow class:

If the required logic for the get method is not defined, a LogicError will be thrown.

update method

The update method is used to update details of the specified item:

When using the update method, its required logic must also be defined:

If the logic for the update method is not defined, it will throw a LogicError.

Using EloquentDepot

The EloquentDepot class provides a pre-built implementation of Depot that delegates all CRUD operations to an Eloquent Model:

Once defined, all CRUD methods are available out of the box:

[!NOTE] The EloquentDepot class requires the illuminate/database package, which should be installed as a dependency:

Filtering results

The get method supports filtering through the withFilter method. Use the Filter class to add WHERE clauses to the paginated query:

The specified filters can be used as as* method in getItems:

To identify filter fields as searchable (using LIKE), use the withSearch method:

The searchable fields can be used in the depot with getSearchKeys method:

Using Route

The Route class in Dexter is similar to the previously discussed Depot class. While the Depot class conforms to the CRUD operations, the Route class closely follows the RESTful software architecture style and uses the PSR-07 standard for standardization of its HTTP responses:

The Route class contains the following methods for writing their logic:

is[METHOD]Valid

This method will be triggered if [METHOD] requires to be validated first. If not specified, it always return to true by default:

invalid[METHOD]

This method will be triggered if the is[METHOD]Valid method returns to false. This should return an HTTP response with an HTTP code between 4xx to 5xx:

set[METHOD]Data

This is the main method that requires to write its logic based on [METHOD]:

Using this kind of approach improves the code structure of HTTP routes as it only requires to write the logic for each Route method that is being used (e.g., index).

[!NOTE] In other PHP frameworks and other guides, Route is also known as Controller.

delete method

The delete method is an HTTP route which can be used for deleting a specified item:

index method

The index method should return an array of items as its HTTP response:

show method

The show method returns an HTTP response for the specified item:

store method

The store method should be responsible for creating new items to the specified storage:

update method

The update method updates the details of a specified item:

Unified validation

When multiple actions share the same validation logic, use the invalid, isAllowed, and isDataValid methods to avoid duplication.

invalid

Returns an error response for any action. The $code parameter defaults to 400:

All per-action methods (e.g., invalidDelete, invalidStore, etc.) are delegated to this method by default. Override the invalid method once when the error response is the same for all actions.

isAllowed

Checks whether the action is allowed (e.g., checking if the user is authorized):

All action methods delegated to this method by default. Override this method if all actions must have the same authorization logic.

isDataValid

Checks whether the payload data is valid for the store and update actions:

The isStoreValid and isUpdateValid methods are only delegated to methods isAllowed and isDataValid.

Changelog

Please see CHANGELOG for more recent changes.

Contributing

See CONTRIBUTING on how to contribute.

License

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


All versions of dexter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
psr/http-message Version ~1.0|~2.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 rougin/dexter contains the following files

Loading the files please wait ...