PHPackages                             jerfeson/slim4-skeleton - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. jerfeson/slim4-skeleton

ActiveProject[Templating &amp; Views](/categories/templating)

jerfeson/slim4-skeleton
=======================

Slim4 skeleton (http + cli + oauth2) with some add-ons out of the box

v2.0.0(4y ago)11384MITJavaScriptPHP ^7.2

Since May 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jerfeson/slim4-skeleton)[ Packagist](https://packagist.org/packages/jerfeson/slim4-skeleton)[ RSS](/packages/jerfeson-slim4-skeleton/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (27)Versions (8)Used By (0)

Slim Framework 4 Skeleton Application (http + cli)
==================================================

[](#slim-framework-4-skeleton-application-http--cli)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b6ebd4f89ade66f0f71a78ef6bcceed49c8b9b2da0340b058b4f04980b401233/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6a65726665736f6e2f736c696d342d736b656c65746f6e2e737667)](https://img.shields.io/github/v/release/jerfeson/slim4-skeleton)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Build Status](https://github.com/jerfeson/slim4-skeleton/workflows/build/badge.svg)](https://github.com/jerfeson/slim4-skeleton/actions)[![Total Downloads](https://camo.githubusercontent.com/2465bd4506a55cb105f13ab1788b55d6276899357af1e88675a569f105647344/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a65726665736f6e2f736c696d342d736b656c65746f6e2e737667)](https://img.shields.io/github/downloads/jerfeson/slim4-skeleton/total)

[![Landing Page](screenshot.png)](screenshot.png)

Use this skeleton application to quickly setup and start working on a new Slim Framework 4 application (Tested with slim 4.5). This application handles http and command line requests. This application ships with a few service providers and a Session middleware out of the box. Supports container resolution and auto-wiring.

To remove a service provider comment it on config/app.php file and remove it from composer.json, update composer.

Available service providers:

- [SlashTrace](https://github.com/slashtrace/slashtrace)
- [Monolog](https://github.com/Seldaek/monolog)
- [Eloquent](https://github.com/illuminate/database)
- [Twig](https://github.com/twigphp/Twig)
- [FlySystem](https://github.com/thephpleague/flysystem)
- [Redis Cache](https://github.com/naroga/redis-cache)
- [Flash Message](https://github.com/slimphp/Slim-Flash)
- [Codeception](https://codeception.com)
- [oAuth2](https://oauth2.thephpleague.com/)
- [Validation](https://github.com/jerfeson/slim-validation)
- [CSRF](https://github.com/slimphp/Slim-Csrf)

Requirements
------------

[](#requirements)

- PHP 7.2+ (with json extensions)
- MySQL 5.7+ or MariaDB
- Openssl
- Composer (only for development)

### Install the Application

[](#install-the-application)

Run this command from the directory in which you want to install your new Slim Framework application.

```
php composer.phar create-project jerfeson/slim4-skeleton [my-app-name]

```

Replace `[my-app-name]` with the desired directory name for your new application. You'll want to:

- Point your virtual host document root to your new application's `public/` directory.
- Install the dependencies `composer install --prefer-dist --no-progress`.
- Ensure `storage/` is web writable.
- make the necessary changes in config file config/app.php

Set permissions (Linux only)
----------------------------

[](#set-permissions-linux-only)

```
sudo chown -R www-data storage/
sudo chmod -R ug+w storage/

sudo chmod -R 760 storage/

chmod +x bin/console.php

```

Database setup
--------------

[](#database-setup)

Create a new database for development

```
mysql -e 'CREATE DATABASE IF NOT EXISTS slim_skeleton'

```

Copy the file: config/env.example.php to config/development.php

```
cp config/env.exemplo.php config/development.php

```

Change the connection configuration in config/development.php:

```
'settings' => [
    'database' => [
        'default' => [
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'default',
            'username'  => '',
            'password'  => '',

```

Migrations
----------

[](#migrations)

Use the command for create initial tables, used in oAuth2

```
php bin/console.php migrations or composer console:migration

```

Go to the `data/keys/oauth` folder and create your project's public and private keys

#### Generating public and private keys

[](#generating-public-and-private-keys)

The public/private key pair is used to sign and verify JWTs transmitted. The Authorization Server possesses the private key to sign tokens and the Resource Server possesses the corresponding public key to verify the signatures. To generate the private key run this command on the terminal:

```
openssl genrsa -out private.key 2048

```

If you want to provide a passphrase for your private key run this command instead:

```
 openssl genrsa -passout pass:_passphrase_ -out private.key 2048

```

then extract the public key from the private key:

```
openssl rsa -in private.key -pubout -out public.key

```

or use your passphrase if provided on private key generation:

```
openssl rsa -in private.key -passin pass:_passphrase_ -pubout -out public.key

```

The private key must be kept secret (i.e. out of the web-root of the authorization server). The authorization server also requires the public key.

If a passphrase has been used to generate private key it must be provided to the authorization server.

The public key should be distributed to any services (for example resource servers) that validate access tokens.

#### Generating encryption keys

[](#generating-encryption-keys)

Encryption keys are used to encrypt authorization and refresh codes. The AuthorizationServer accepts two kinds of encryption keys, a string password or a \\Defuse\\Crypto\\Key object from the [Secure PHP Encryption Library](https://github.com/defuse/php-encryption).

##### string password

[](#string-password)

A `string` password can vary in strength depending on the password chosen. To turn it into a strong encryption key the [PBKDF2](https://github.com/defuse/php-encryption) key derivation function is used. This function derives an encryption key from a password and is slow by design. It uses a lot of CPU resources for a fraction of a second, applying key stretching to the password to reduce vulnerability to brute force attacks.

To generate a `string` password for the `AuthorizationServer`, you can run the following command in the terminal:

```
php -r 'echo base64_encode(random_bytes(32)), PHP_EOL;'

```

Replace the value of OAuthServer::ENCRYPTION\_KEY

##### Key object

[](#key-object)

A `\Defuse\Crypto\Key` is a strong encryption key. This removes the need to use a slow key derivation function, reducing encryption and decryption times compared to using a string password.

A `Key` can be generated with the `generate-defuse-key` script. To generate a `Key` for the `AuthorizationServer` run the following command in the terminal:

```
vendor/bin/generate-defuse-key

```

Replace the value of OAuthServer::ENCRYPTION\_KEY

The string can be loaded as a Key with Key::loadFromAsciiSafeString(self::ENCRYPTION\_KEY).

### Run it:

[](#run-it)

1. `$ cd [my-app-name]\public`
2. `$ php -S localhost:8080`
3. Browse to

### Key directories

[](#key-directories)

- `app`: Application code (models, controllers, cli commands, handlers, middleware, service providers and others)
- `config`: Configuration files like db, mail, routes...
- `lib`: Other project classes like utils, business logic and framework extensions
- `resources`: Views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript.
- `storage`: Log files, cache files...
- `public`: The public directory contains `index.php` file, assets such as images, JavaScript, and CSS
- `teste`: The directory contains all tests using in codeception
- `vendor`: Composer dependencies

### Console usage

[](#console-usage)

- Usage: php bin/console.php \[command-name\]
- List: php bin/console.php For list all commands How to create a new command:

1. Create a class under directory app\\Console in namespace App\\Console
2. Your class should extend Symfony\\Component\\Console\\Command\\Command
3. DONE!

Example:

Command class:

```
namespace App\Console;

use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ExampleCommand extends Command
{
    /**
     * @var ContainerInterface
     */
    private $container;

    /**
     * Constructor.
     *
     * @param ContainerInterface $container The container
     * @param string|null $name The name
     */
    public function __construct(ContainerInterface $container, ?string $name = null)
    {
        parent::__construct($name);
        $this->container = $container;
    }

    /**
     * Configure.
     *
     * @return void
     */
    protected function configure(): void
    {
        parent::configure();

        $this->setName('example');
        $this->setDescription('A sample command');
    }

    /**
     * Execute command.
     *
     * @param InputInterface $input The input
     * @param OutputInterface $output The output
     *
     * @return int The error code, 0 on success
     */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->writeln(sprintf('Hello, console'));
        return 0;
    }
}
```

Execute the class:method from command line:

```
php bin/console.php example
```

### Code examples

[](#code-examples)

Get application instance

```
$app = \Lib\Framework\App::instance();
// or simpler using a helper function
$app = app();
```

### Codeception test examples

[](#codeception-test-examples)

Have the version 79 of chrome installed. otherwise, [download](https://sites.google.com/a/chromium.org/chromedriver/downloads) your version driver

go to the test folder and run the following command. (Windows)

```
tests/_drivers/chromedriver.exe --url-base=/wd/hub

```

go to the test folder and run the following command. (linux)

```
./tests/_drivers/chromedriver --url-base=/wd/hub

```

go to project folder and run the following command.

```
./vendor/bin/codecept run --steps

```

or

```
php vendor/bin/codecept run --steps

```

Roadmap
-------

[](#roadmap)

- more service providers
- more code examples

Contributing
------------

[](#contributing)

- welcome to discuss a bugs, features and ideas.

License
-------

[](#license)

jerfeson/slim4-skeleton is release under the MIT license.

Thanks
------

[](#thanks)

This project is based on the project in [jupitern/slim3-skeleton](https://github.com/jupitern/slim3-skeleton) feel free to contribute to this and the other project.

- [jupitern](https://github.com/jupitern)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~93 days

Total

5

Last Release

1812d ago

Major Versions

v1.2.0 → v2.0.02021-05-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/f318ad28c5ab51c42da3afbfac025a6fbcf5f5d04866fcd533b55e2005f0b267?d=identicon)[jerfeson](/maintainers/jerfeson)

---

Top Contributors

[![jerfeson](https://avatars.githubusercontent.com/u/2961357?v=4)](https://github.com/jerfeson "jerfeson (218 commits)")

---

Tags

oauth2slim4twigslimnginxSkeletonapacheslim4slim-framework

###  Code Quality

TestsCodeception

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jerfeson-slim4-skeleton/health.svg)

```
[![Health](https://phpackages.com/badges/jerfeson-slim4-skeleton/health.svg)](https://phpackages.com/packages/jerfeson-slim4-skeleton)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[havenshen/slim-born

Slim Framework 3 skeleton application has authentication.

1941.7k](/packages/havenshen-slim-born)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
