Download the PHP package thispagecannotbefound/silex-action-controller without Composer

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

SilexActionController

Extended controller functionality for Silex.

Introduction -- workflow

I have developed a personal workflow in which I organize my controllers in classes, while keeping Silex functionality. This is different from Silex's ServiceControllerServiceProvider, because that is meant to completely separate your controllers from the framework. In my controllers I want to have the framework functionality, for example to redirect requests or return a JSON response. Small example controller:

class UserController
{
    function getUser($name) {
        $user = $this->app['service.user']->getByName($name);

        if ($user) {
            return $this->app['twig']->render('user.twig');
        }

        return $this->app->redirect('/noUser');
    }
}

I like this way of organizing my code, which to some extent resembles Symfony 2's and Zend Framework 2's method of controller classes. This Silex extension makes this workflow less verbose.

README example classes

To explain the usage of this extension, the following example classes are used:

Example\ServiceController

namespace Example;

class ServiceController
{
    function show() {
        return __METHOD__;
    }
}

Example\ActionController

namespace Example;

use Silex\Application;
use ThisPageCannotBeFound\Silex\ApplicationAwareInterface;

class ApplicationAwareController implements ApplicationAwareInterface
{
    protected $app;

    function setApplication(Application $app) {
        $this->app = $app;
    }

    function show() {
        return __METHOD__;
    }
}

Usage

ActionControllerServiceProvider

First you'll need to register the provider with your app, after which you can define controllers:

use Silex\Application;
use ThisPageCannotBeFound\Silex\Provider\ActionControllerServiceProvider;

$app = new Application();

$app->register(new ActionControllerServiceProvider());

// Map controller, comparable to Silex's ServiceControllerServiceProvider,
// except by using just the controller class name. The service provider will
// create the class instance for you.
$app['controller.example.service'] = 'Example\\ServiceController';
$app['controller.example.action'] = 'Example\\ActionController';

Defining routes: 'service controller'

// Map route to a class method.
$app->get('/example', 'controller.example.service:show');

Defining routes: 'action controller'

// Map route to an entire class, method will be the action parameter.
$app->get('/example/{action}', 'controller.example.action');

ApplicationAwareInterface

Implement this interface to have the ActionControllerServiceProvider inject a Silex app instance into the class. (see ApplicationAwareController example class)

AbstractController

This class provides helper methods to make the calls cleaner. It contains the Silex Application request - response methods (e.g. redirect, abort) and the methods from the default service providers, copied from their traits. It also implements the ApplicationAwareInterface, so it receives the Application instance upon instantiation. This class can be extended to add functionality to your controller classes.

Example - revised UserController:

class UserController extends AbstractController
{
    function getUser($name) {
        $user = $this->app['service.user']->getByName($name);

        if ($user) {
            return $this->render('user.twig');
        }

        return $this->redirect('/noUser');
    }
}

All versions of silex-action-controller with dependencies

PHP Build Version
Package Version
Requires silex/silex Version 1.*
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 thispagecannotbefound/silex-action-controller contains the following files

Loading the files please wait ....