{"id":23450733,"url":"https://github.com/omotsuebe/slim-starter","last_synced_at":"2025-04-13T20:15:03.124Z","repository":{"id":56984123,"uuid":"417470226","full_name":"omotsuebe/slim-starter","owner":"omotsuebe","description":"Slim Framework 4 Starter App","archived":false,"fork":false,"pushed_at":"2021-10-25T08:01:00.000Z","size":64,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T20:14:53.226Z","etag":null,"topics":["authentication","mysql","php","php-framework","php74","php8","postgresql","slim","slim-4","slim-framework","sqlite","twig"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omotsuebe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-15T11:10:25.000Z","updated_at":"2024-04-01T17:49:13.000Z","dependencies_parsed_at":"2022-08-21T09:10:36.596Z","dependency_job_id":null,"html_url":"https://github.com/omotsuebe/slim-starter","commit_stats":null,"previous_names":["omotsuebe/slim-starter","hezecom/slim-starter"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omotsuebe%2Fslim-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omotsuebe%2Fslim-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omotsuebe%2Fslim-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omotsuebe%2Fslim-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omotsuebe","download_url":"https://codeload.github.com/omotsuebe/slim-starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248774968,"owners_count":21159534,"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":["authentication","mysql","php","php-framework","php74","php8","postgresql","slim","slim-4","slim-framework","sqlite","twig"],"created_at":"2024-12-24T00:14:36.936Z","updated_at":"2025-04-13T20:15:03.097Z","avatar_url":"https://github.com/omotsuebe.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slim Framework 4 Starter App\n\n\u003e Slim Framework 4 skeleton MVC application with build in authentication system.\n\n## Features\n\n * Light weight and organised for easy understanding.\n * Simple, fast routing engine.\n * Highly secured, ready to use authentication system.\n * Simplify helper function for faster development.\n * Build in email notification.\n * Build in email templates (can easily be modified)\n * PSR-7 implementation and PHP-DI container implementation\n * Detailed HTML error reporting.\n\n## Requirements\n\n * PHP 7.4 | 8.0+\n * PDO PHP Extension\n * Suport MySQL 5.5.3+ **or** MariaDB 5.5.23+ **or** PostgreSQL 9.5.10+ **or** SQLite 3.14.1+ ...\n\n## Installation\n\n\n\n```shell\ncomposer create-project \"hezecom/slim-starter v1.0\" [my-app]\n```\n**`Database (Required for auth to work)`**\n* Create a database or use existing database to import/copy to your SQL console to create required tables for the authentication.\n* Dasbase option (MySQL, SQLite or PostgreSQL)\n* Database file is located at **/`database`**\n\n## .env\n\nCopy file .env.example to .env\n\n```\nDB_DRIVER=mysql\nDB_HOST=localhost\nDB_DATABASE=slimapp\nDB_USERNAME=root\nDB_PASSWORD=\nDB_PORT=3306\n\n# Email setting Driver = (smtp | sendmail | mail)\nMAIL_DRIVER=smtp\nMAIL_HOST=smtp.mailtrap.io\nMAIL_PORT=2525\nMAIL_USERNAME=username\nMAIL_PASSWORD=password\nMAIL_ENCRYPTION=tls\nMAIL_FROM_ADDRESS='info@example.com'\nMAIL_FROM_NAME='Example'\n```\n\n## Router\n\nRouting example below\n\n```php\n\u003c?php\n\n$app-\u003eget('/', 'HomeController:index')-\u003esetName('home');\n\n$app-\u003egroup('', function ($route) {\n    $route-\u003eget('/register', AuthController::class . ':createRegister')-\u003esetName('register');\n    $route-\u003epost('/register', AuthController::class . ':register');\n    $route-\u003eget('/login', AuthController::class . ':createLogin')-\u003esetName('login');\n    $route-\u003epost('/login', AuthController::class . ':login');\n\n    $route-\u003eget('/verify-email', AuthController::class.':verifyEmail')-\u003esetName('verify.email');\n    $route-\u003eget('/verify-email-resend',AuthController::class.':verifyEmailResend')-\u003esetName('verify.email.resend');\n\n    $route-\u003eget('/forgot-password', PasswordController::class . ':createForgotPassword')-\u003esetName('forgot.password');\n    $route-\u003epost('/forgot-password', PasswordController::class . ':forgotPassword');\n    $route-\u003eget('/reset-password', PasswordController::class.':resetPassword')-\u003esetName('reset.password');\n    $route-\u003eget('/update-password', PasswordController::class.':createUpdatePassword')-\u003esetName('update.password');\n    $route-\u003epost('/update-password', PasswordController::class.':updatePassword');\n\n})-\u003eadd(new GuestMiddleware($container));\n```\n\n## Controller\n\nController example simplify\n```php\n\u003c?php\n\nnamespace App\\Controllers;\n\nclass HomeController extends Controller\n{\n\tpublic function index(Request $request, Response $response)\n\t{\n\t\treturn view($response,'index.twig');\n\t}\n}\n```\n\n## Model\n\nUses Eloquent ORM used by Laravel Framework. It currently supports MySQL, Postgres, SQL Server, and SQLite.\nReference - [illuminate/database](https://github.com/illuminate/database)\n```php\n\u003c?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass User extends Model\n{\n\tprotected $table = 'users';\n\n\tprotected $fillable = [\n\t\t'email',\n\t\t'username',\n\t\t'password',\n\t];\n\n}\n```\n\n## Middleware\n\n```php\n\u003c?php\n\nnamespace App\\Middleware;\n\nuse Psr\\Http\\Message\\ServerRequestInterface as Request;\nuse Psr\\Http\\Server\\RequestHandlerInterface as RequestHandler;\n\nclass AuthMiddleware extends Middleware\n{\n\tpublic function __invoke(Request $request, RequestHandler $handler)\n\t{\n\t   if(! $this-\u003econtainer-\u003eget('auth')-\u003eisLogin()) {\n              return redirect()-\u003eroute('login')-\u003ewith('error', 'Access denied, you need to login.');\n            }\n        $response = $handler-\u003ehandle($request);\n        return $response;\n\t}\n}\n```\n\n## Validation\n\nUse the most awesome validation engine ever created for PHP.\nReference - [Respect/Validation](https://github.com/Respect/Validation)\n```php\n\u003c?php\nnamespace App\\Controllers\\Auth;\nuse App\\Controllers\\Controller;\nuse Respect\\Validation\\Validator as v;\n\nclass AuthController extends Controller\n{\n\tpublic function register(Request $request, Response $response)\n\t{\n\t\t$validation = $this-\u003evalidator-\u003evalidate($request, [\n\t\t\t'email' =\u003e v::noWhitespace()-\u003enotEmpty()-\u003eemail(),\n                        'username' =\u003e v::noWhitespace()-\u003enotEmpty()-\u003ealnum(),\n                        'password' =\u003e v::notEmpty()-\u003estringType()-\u003elength(8),\n\t\t]);\n\n\t\tif ($validation-\u003efailed()) {\n\t\t    redirect()-\u003eroute('register');\n\t\t}\n\n\t\t//\tmore coding here\n\t}\n}\n```\n\n## More basic functions\n\nreference slim official documents - [Slim Framework](http://www.slimframework.com/docs/)\n\n\n\n## Directory Structure\n\n```shell\n|-- slim-born\n\t|-- app\n\t\t|-- Auth\n\t\t|-- Controllers\n\t\t|-- Middleware\n\t\t|-- Models\n\t\t|-- Lib\n\t    |-- bootstrap\n\t\t|-- app.php\n        |-- database.php\n        |-- helper.php\n    |-- logs\n\t|-- public\n\t|-- resources\n    |-- route\n\t....\n```\n\n## Testing\n\n``` bash\n$ phpunit\n```\n\n## Contributing\n\nAll contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed.\n\n## License\n\nThis project is licensed under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomotsuebe%2Fslim-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomotsuebe%2Fslim-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomotsuebe%2Fslim-starter/lists"}