{"id":15043861,"url":"https://github.com/jerfeson/slim4-skeleton","last_synced_at":"2025-09-19T17:32:58.370Z","repository":{"id":43110716,"uuid":"260563567","full_name":"jerfeson/slim4-skeleton","owner":"jerfeson","description":"Slim4 skeleton (http + cli + oauth2) with some add-ons out of the box","archived":false,"fork":false,"pushed_at":"2023-07-04T05:24:30.000Z","size":7340,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T12:38:43.209Z","etag":null,"topics":["oauth2","slim4","twig"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jerfeson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-01T21:39:47.000Z","updated_at":"2025-01-31T07:02:40.000Z","dependencies_parsed_at":"2024-09-25T01:51:18.045Z","dependency_job_id":"f1a36343-92d9-4a32-ad06-87307e7efc72","html_url":"https://github.com/jerfeson/slim4-skeleton","commit_stats":{"total_commits":213,"total_committers":1,"mean_commits":213.0,"dds":0.0,"last_synced_commit":"6a4b4ae520ae470bceb9be5c302b45e5852fc880"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerfeson%2Fslim4-skeleton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerfeson%2Fslim4-skeleton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerfeson%2Fslim4-skeleton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerfeson%2Fslim4-skeleton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jerfeson","download_url":"https://codeload.github.com/jerfeson/slim4-skeleton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248984279,"owners_count":21193717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oauth2","slim4","twig"],"created_at":"2024-09-24T20:49:43.321Z","updated_at":"2025-09-19T17:32:58.217Z","avatar_url":"https://github.com/jerfeson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slim Framework 4 Skeleton Application (http + cli)\n\n[![Latest Version on Packagist](https://img.shields.io/github/release/jerfeson/slim4-skeleton.svg)](https://img.shields.io/github/v/release/jerfeson/slim4-skeleton)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md)\n[![Build Status](https://github.com/jerfeson/slim4-skeleton/workflows/build/badge.svg)](https://github.com/jerfeson/slim4-skeleton/actions)\n[![Total Downloads](https://img.shields.io/packagist/dt/jerfeson/slim4-skeleton.svg)](https://img.shields.io/github/downloads/jerfeson/slim4-skeleton/total)\n\n![Landing Page](screenshot.png)\n\nUse 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.\n\nTo remove a service provider comment it on config/app.php file and remove it from composer.json, update composer.\n\nAvailable service providers:\n\n- [SlashTrace]\n- [Monolog]\n- [Eloquent]\n- [Twig]\n- [FlySystem]\n- [Redis Cache]\n- [Flash Message]\n- [Codeception]\n- [oAuth2]\n- [Validation]\n- [CSRF]\n\n## Requirements\n\n* PHP 7.2+ (with json extensions)\n* MySQL 5.7+ or MariaDB\n* Openssl\n* Composer (only for development)\n\n### Install the Application\n\nRun this command from the directory in which you want to install your new Slim Framework application.\n\n    php composer.phar create-project jerfeson/slim4-skeleton [my-app-name]\n\nReplace `[my-app-name]` with the desired directory name for your new application. You'll want to:\n\n* Point your virtual host document root to your new application's `public/` directory.\n* Install the dependencies `composer install --prefer-dist --no-progress`.\n* Ensure `storage/` is web writable.\n* make the necessary changes in config file config/app.php\n\n## Set permissions (Linux only)\n\n    sudo chown -R www-data storage/\n    sudo chmod -R ug+w storage/\n\n    sudo chmod -R 760 storage/\n\n    chmod +x bin/console.php\n\n## Database setup\nCreate a new database for development\n\n    mysql -e 'CREATE DATABASE IF NOT EXISTS slim_skeleton'\n\nCopy the file: config/env.example.php to config/development.php\n\n    cp config/env.exemplo.php config/development.php\n\nChange the connection configuration in config/development.php:\n\n    'settings' =\u003e [\n        'database' =\u003e [\n            'default' =\u003e [\n                'driver'    =\u003e 'mysql',\n                'host'      =\u003e 'localhost',\n                'database'  =\u003e 'default',\n                'username'  =\u003e '',\n                'password'  =\u003e '',\n\n\n## Migrations\n\nUse the command for create initial tables, used in oAuth2\n\n    php bin/console.php migrations or composer console:migration\n\nGo to the `data/keys/oauth` folder and create your project's public and private keys\n\n#### Generating public and private keys\n\nThe 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:\n\n    openssl genrsa -out private.key 2048\n\nIf you want to provide a passphrase for your private key run this command instead:\n\n     openssl genrsa -passout pass:_passphrase_ -out private.key 2048\n\nthen extract the public key from the private key:\n\n    openssl rsa -in private.key -pubout -out public.key\n\nor use your passphrase if provided on private key generation:\n\n    openssl rsa -in private.key -passin pass:_passphrase_ -pubout -out public.key\n\nThe 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.\n\nIf a passphrase has been used to generate private key it must be provided to the authorization server.\n\nThe public key should be distributed to any services (for example resource servers) that validate access tokens.\n\n#### Generating encryption keys\n\nEncryption 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].\n\n##### string password\n\nA `string` password can vary in strength depending on the password chosen. To turn it into a strong encryption key the [PBKDF2] 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.\n\nTo generate a `string` password for the `AuthorizationServer`, you can run the following command in the terminal:\n\n    php -r 'echo base64_encode(random_bytes(32)), PHP_EOL;'\n\nReplace the value of OAuthServer::ENCRYPTION_KEY\n\n##### Key object\n\nA `\\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.\n\nA `Key` can be generated with the `generate-defuse-key` script. To generate a `Key` for the `AuthorizationServer` run the following command in the terminal:\n\n    vendor/bin/generate-defuse-key\n\nReplace the value of OAuthServer::ENCRYPTION_KEY\n\nThe string can be loaded as a Key with Key::loadFromAsciiSafeString(self::ENCRYPTION_KEY).\n\n### Run it:\n\n1. `$ cd [my-app-name]\\public`\n2. `$ php -S localhost:8080`\n3. Browse to http://localhost:8080\n\n### Key directories\n\n* `app`:        Application code (models, controllers, cli commands, handlers, middleware, service providers and others)\n* `config`:     Configuration files like db, mail, routes...\n* `lib`:        Other project classes like utils, business logic and framework extensions\n* `resources`:  Views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript.\n* `storage`:    Log files, cache files...\n* `public`:     The public directory contains `index.php` file, assets such as images, JavaScript, and CSS\n* `teste`:      The directory contains all tests using in codeception\n* `vendor`:     Composer dependencies\n\n### Console usage\n\n* Usage: php bin/console.php [command-name]\n* List: php bin/console.php For list all commands\nHow to create a new command:\n 1. Create a class under directory app\\Console in namespace App\\Console\n 2. Your class should extend Symfony\\Component\\Console\\Command\\Command\n 4. DONE!\n\nExample:\n\nCommand class:\n```php\nnamespace App\\Console;\n\nuse Psr\\Container\\ContainerInterface;\nuse Symfony\\Component\\Console\\Command\\Command;\nuse Symfony\\Component\\Console\\Input\\InputInterface;\nuse Symfony\\Component\\Console\\Output\\OutputInterface;\n\nclass ExampleCommand extends Command\n{\n    /**\n     * @var ContainerInterface\n     */\n    private $container;\n\n    /**\n     * Constructor.\n     *\n     * @param ContainerInterface $container The container\n     * @param string|null $name The name\n     */\n    public function __construct(ContainerInterface $container, ?string $name = null)\n    {\n        parent::__construct($name);\n        $this-\u003econtainer = $container;\n    }\n\n    /**\n     * Configure.\n     *\n     * @return void\n     */\n    protected function configure(): void\n    {\n        parent::configure();\n\n        $this-\u003esetName('example');\n        $this-\u003esetDescription('A sample command');\n    }\n\n    /**\n     * Execute command.\n     *\n     * @param InputInterface $input The input\n     * @param OutputInterface $output The output\n     *\n     * @return int The error code, 0 on success\n     */\n    protected function execute(InputInterface $input, OutputInterface $output): int\n    {\n        $output-\u003ewriteln(sprintf('\u003cinfo\u003eHello, console\u003c/info\u003e'));\n        return 0;\n    }\n}\n```\n\nExecute the class:method from command line:\n\n```php\nphp bin/console.php example\n```\n\n### Code examples\n\nGet application instance\n```php\n$app = \\Lib\\Framework\\App::instance();\n// or simpler using a helper function\n$app = app();\n```\n\n### Codeception test examples\n\nHave the version 79 of chrome installed. otherwise, [download] your version driver\n\ngo to the test folder and run the following command. (Windows)\n```\ntests/_drivers/chromedriver.exe --url-base=/wd/hub\n```\ngo to the test folder and run the following command. (linux)\n```\n./tests/_drivers/chromedriver --url-base=/wd/hub\n```\ngo to project folder and run the following command.\n\n```\n./vendor/bin/codecept run --steps\n```\nor\n```\nphp vendor/bin/codecept run --steps\n```\n\n## Roadmap\n\n - [ ] more service providers\n - [ ] more code examples\n\n## Contributing\n\n - welcome to discuss a bugs, features and ideas.\n\n## License\n\njerfeson/slim4-skeleton  is release under the MIT license.\n\n## Thanks\n\nThis project is based on the project in [jupitern/slim3-skeleton] feel free to contribute to this and the other project.\n\n- [jupitern]\n\n[jupitern]: https://github.com/jupitern\n[jupitern/slim3-skeleton]: https://github.com/jupitern/slim3-skeleton\n\n[SlashTrace]:https://github.com/slashtrace/slashtrace\n[Monolog]:https://github.com/Seldaek/monolog\n[Eloquent]:https://github.com/illuminate/database\n[Twig]:https://github.com/twigphp/Twig\n[Flash Message]:https://github.com/slimphp/Slim-Flash\n[Codeception]:https://codeception.com\n[download]:https://sites.google.com/a/chromium.org/chromedriver/downloads\n[oAuth2]:https://oauth2.thephpleague.com/\n[Eloquent]:https://github.com/illuminate/database\n[FlySystem]:https://github.com/thephpleague/flysystem\n[Redis Cache]:https://github.com/naroga/redis-cache\n[Secure PHP Encryption Library]:https://github.com/defuse/php-encryption\n[PBKDF2]:https://github.com/defuse/php-encryption\n[Validation]:https://github.com/jerfeson/slim-validation\n[CSRF]:https://github.com/slimphp/Slim-Csrf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerfeson%2Fslim4-skeleton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerfeson%2Fslim4-skeleton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerfeson%2Fslim4-skeleton/lists"}