An application template for Slim 3






Installs: 90

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0


v1.0.0 2020-07-25 14:58 UTC

This package is auto-updated.

Last update: 2020-07-25 15:00:07 UTC


Adding some fat to Slim Framework.

Chubby provides a working Slim application template around which additional fat is added in the form of modules.

The first of these modules is Chubby View, a PHP renderer that offers a very convenient way of organizing code.

Install via Composer

Go to the directory where you want the new application to sit, then create the project:

composer create-project a3gz/chubby -s dev

This will create a new project called chubby.

Once the project has been created you can safely delete the chubby/composer.json file and the chubby/vendor directory. Don't delete the file chubby/src/composer.json thought, this one is wher you add your dependencies.

Chubby needs all required dependencies to sit on the src directory:

> cd chubby/src
> composer install

Finally go to your browser and request:


It's very unlikely that you'll want your application to be called chubby, so you may want to rename that directory.

It is also possible to do this when you create the project:

composer create-project a3gz/chubby my-app -s dev

Now your application is in ./my-app.

Running with Docker Compose

docker-compose up [-d]

The provided docker-compose.yml maps to the host's 9999 port so you should be able to see the site in the following local address:


Console request

php console.php path to resource

The above command will invoke the route: /path/to/resource.

Why Chubby at all?

Chubby is a working application template that offers one possible implementation of the application structure proposed in Slim's documentation.

Around that idea Chubby sets the foundations to split the application files in a way that the code can be placed outside the public_html directory, among other things.


Chubby assumes the existence of a src/app/config directory containing at least one file called config.php. This file should return an associateive array with settings that will be passed to the Slim application's constructor.

Optionally we can provide Slim with additional dependencies by adding more files inside the config directory. Each file must return one dependency. Take the provided logger.php for instance:

return function($c) {
    $appName =  basename(PUBLIC_APP_PATH);
    $logFileName = dirname(__DIR__) . "/{$appName}.local.log"; 
    $logger = new \Monolog\Logger($appName);
    $file_handler = new \Monolog\Handler\StreamHandler( $logFileName );
    return $logger;   

Chubby will inject the dependency in Slim's container under the same name as the file, in this case: logger: $container['logger'].

Contact the author

I would welcome comments, suggestions and brainstorming-like ideas.