Download the PHP package havokinspiration/cakephp-actions-class without Composer

On this page you can find all versions of the php package havokinspiration/cakephp-actions-class. 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 cakephp-actions-class

CakePHP ActionsClass plugin

Build Status codecov.io

This plugin gives you the ability to manage your CakePHP Controller actions as single classes. Each action of your Controllers will be managed in its own object.

Requirements

Installation

You can install this plugin into your CakePHP application using Composer.

The recommended way to install it is:

Loading the plugin

It is recommanded to load this plugin using the bootstrap() method of your application's Application class. This is needed if you want to be able to use Integration testing:

Loading the plugin bootstrap file is mandatory.

Usage

By default, CakePHP controller management is based around one controller (which represents one part of your application, for instance "Posts") which is a single class containing one public method per actions needed to be exposed in your application:

As your application grows, your controllers grow as well. In the end, on large applications, you can end up with big controller files with lots of content, making it hard to read through. You might even be in the case where you need to have methods specific to some actions in the middle of other methods dedicated to other actions.

This is where the cakephp-actions-class plugin is useful. When enabled, you can have your controllers actions as single classes.

So the PostsController example given above would become:

Living in the following directory structure :

Your Action classes are only expected to hold an execute() method. It can receive passed parameters as in regular controller actions (meaning the URL /posts/edit/5 will pass 5 to the argument $id in the execute() method of the EditAction class in our previous example).

Using the bake command-line to create Action classes

You first need to load the plugin in your config/bootstrap_cli.php :

You can then create an Action class file with the following command :

The command expects the name to get the controller name and the action name separated by a forward slash. For instance, the above example would create a IndexAction file for the Posts controller.

You can also specify the routing prefix your controller action lives under by using the --prefix option :

If you want to create an action file for a plugin, you can use the --plugin option :

You can of course use both together :

By default, baking an action class will generate the corresponding test file. You can skip the test file generation by using the --no-test boolean flag :

Compatibility

This plugin was designed to have a maximum compatibility with the regular CakePHP behavior.

Fallback to CakePHP regular behavior

If you wish to use this plugin in an existing application, it will first try to provide a response using an Action class. If an action class matching the routing parameters can not be found, it will let CakePHP fallback to its regular behavior (meaning looking for a Controller class).

This also means that you can develop a plugin with controllers implementing this behavior without breaking the base application (since, when the cakephp-actions-class plugin is loaded, the Dispatcher will first try to load an Action class and fallback to the regular Controller dispatching behavior if it can not find a proper Action class to load).

Everything you do in Controller can be done in an Action class

Under the hood, Action classes are instances of \Cake\Controller\Controller, meaning that everything you do in a regular Controller class can be done in an Action class.
Every events (like beforeFilter or beforeRender) a controller fires are also fired by Action classes.

Loading Components

Actions in Controllers under a routing prefix

Action classes can live under a routing prefix or a plugin :

Integration testing

The plugin is compatible with the Integration testing feature of CakePHP. You just need to follow the same directory pattern as you'd do for you application:

And a basic test file would look like:

Make sure you load the plugin in the App\Application::bootstrap() method, otherwise, Integration tests will not work. See the "Loading the plugin" section of this README to know how to.

No-op methods

As seen above, Action classes are instance of \Cake\Controller\Controller. Some methods in this class are related to actions. But since we are now having objects that represent actions, two methods had to be made "no-op" : \Cake\Controller\Controller::isAction() and \Cake\Controller\Controller::setAction(). Using these methods in an Action subclass will have no effect.

Configuration

Strict Mode

As seen above, the plugin will let CakePHP handle the request in its regular dispatching cycle if an action can not be found. However, if you wish to only use Action classes, you can enable the strict mode. With strict mode enabled, the plugin will throw an exception if it can not find an Action class matching the request currently being resolved.

To enable the strict mode, set it using the Configure object in the bootstrap.php file of your application:

Contributing

If you find a bug or would like to ask for a feature, please use the GitHub issue tracker. If you would like to submit a fix or a feature, please fork the repository and submit a pull request.

Coding standards

This repository follows the PSR-2 standard. Some methods might be prefixed with an underscore because they are an overload from existing methods inside the CakePHP framework.
Coding standards are checked when a pull request is made using the Stickler CI bot.

License

Copyright (c) 2015 - 2017, Yves Piquel and licensed under The MIT License. Please refer to the LICENSE.txt file.


All versions of cakephp-actions-class with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
cakephp/cakephp Version ^3.4
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 havokinspiration/cakephp-actions-class contains the following files

Loading the files please wait ....