Download the PHP package standart/slimcontroller without Composer

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

SlimController

SlimController is an extension for the Slim Framework providing the C of MVC.

With Slim alone, you can create great applications very, very quickly. Sometimes things get out of hand an you just need a bit more structure - or at least I do. That's what SlimController is for.

Install via composer

Create a composer.json file

{
    "require": {
        "slimcontroller/slimcontroller": "dev-master"
    },
    "autoload": {
        "psr-0": {
            "MyApp": "src/"
        }
    }
}

Run installation

composer.phar install --dev

Mini HowTo

If you know how Slim works, using SlimController shouldn't be a big deal.

Example Structure

Setup a structure for your controller and templates (just a suggestion, do as you like):

mkdir -p src/MyApp/Controller templates

Controller

Create your first controller in src/MyApp/Controller/Home.php

templates/home/hello.php

Hello <?= $name ?>

Boostrap index.php

Minimal bootstrap file for this example

<?php

// define a working directory
define('APP_PATH', dirname(__DIR__)); // PHP v5.3+

// load
require APP_PATH . '/vendor/autoload.php';

// init app
$app = New \SlimController\Slim(array(
    'templates.path'             => APP_PATH . '/templates',
    'controller.class_prefix'    => '\\MyApp\\Controller',
    'controller.method_suffix'   => 'Action',
    'controller.template_suffix' => 'php',
));

$app->addRoutes(array(
    '/'            => 'Home:index',
    '/hello/:name' => 'Home:hello',
));

$app->run();

Run

php -S localhost:8080

Controller

Configuration

controller.class_prefix

Optional class prefix for controller classes. Will be prepended to routes.

Using \\MyApp\\Controller as prefix with given routes:

$app->addRoutes(array(
    '/'            => 'Home:index',
    '/hello/:name' => 'Home:hello',
));

Translates to

$app->addRoutes(array(
    '/'            => '\\MyApp\\Controller\\Home:index',
    '/hello/:name' => '\\MyApp\\Controller\\Home:hello',
));

controller.method_suffix

Optional method suffix. Appended to routes.

Using Action as suffix with given routes:

$app->addRoutes(array(
    '/'            => 'Home:index',
    '/hello/:name' => 'Home:hello',
));

Translates to

$app->addRoutes(array(
    '/'            => 'Home:indexAction',
    '/hello/:name' => 'Home:helloAction',
));

controller.template_suffix

Defaults to twig. Will be appended to template name given in render() method.

Extended Examples

Routes

// how to integrate the Slim middleware
$app->addRoutes(array(
    '/' => array(
        'Home:index',
        function() {
            error_log("MIDDLWARE FOR SINGLE ROUTE");
        },
        function() {
            error_log("ADDITIONAL MIDDLWARE FOR SINGLE ROUTE");
        }
    ),
    '/hello/:name' => array(
        'Home:hello',
        'post',
        function() {
            error_log("THIS ROUTE IS ONLY POST");
        }
    )
), function() {
    error_log("APPENDED MIDDLEWARE FOR ALL ROUTES");
});

Controller

<?php

namespace MyApp\Controller;

class Sample extends \SlimController\SlimController
{

    public function indexAction()
    {

        /**
         * Access \SlimController\Slim $app
         */

        $this->app->response()->status(404);

        /**
         * Params
         */

        // reads "?data[foo]=some+value"
        $foo = $this->param('foo');

        // reads "data[bar][name]=some+value" only if POST!
        $bar = $this->param('bar.name', 'post');

        // all params of bar ("object attributes")
        //  "?data[bar][name]=me&data[bar][mood]=happy" only if POST!
        $bar = $this->param('bar');
        //error_log($bar['name']. ' is '. $bar['mood']);

        // reads multiple params in array
        $params = $this->params(array('foo', 'bar.name1', 'bar.name1'));
        //error_log($params['bar.name1']);

        // reads multiple params only if they are POST
        $params = $this->params(array('foo', 'bar.name1', 'bar.name1'), 'post');

        // reads multiple params only if they are POST and all are given!
        $params = $this->params(array('foo', 'bar.name1', 'bar.name1'), 'post', true);
        if (!$params) {
            error_log("Not all params given.. maybe some. Don't care");
        }

        // reads multiple params only if they are POST and replaces non given with defaults!
        $params = $this->params(array('foo', 'bar.name1', 'bar.name1'), 'post', array(
            'foo' => 'Some Default'
        ));

        /**
         * Redirect shortcut
         */

        if (false) {
            $this->redirect('/somewhere');
        }

        /**
         * Rendering
         */

        $this->render('folder/file', array(
            'foo' => 'bar'
        ));

    }
}

All versions of slimcontroller with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
slim/slim Version 2.3.*
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 standart/slimcontroller contains the following files

Loading the files please wait ....