{"id":20364730,"url":"https://github.com/devsavage/slim-3-demo-app","last_synced_at":"2025-07-05T19:05:01.780Z","repository":{"id":72441202,"uuid":"51119716","full_name":"devsavage/slim-3-demo-app","owner":"devsavage","description":"A demo application built with Slim 3.","archived":false,"fork":false,"pushed_at":"2016-07-21T07:56:47.000Z","size":139,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-04T18:46:16.077Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","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/devsavage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2016-02-05T01:58:54.000Z","updated_at":"2018-11-18T21:41:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"ec7a3df9-1f39-4c17-9902-c66d8d5a7af2","html_url":"https://github.com/devsavage/slim-3-demo-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devsavage/slim-3-demo-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsavage%2Fslim-3-demo-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsavage%2Fslim-3-demo-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsavage%2Fslim-3-demo-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsavage%2Fslim-3-demo-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devsavage","download_url":"https://codeload.github.com/devsavage/slim-3-demo-app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsavage%2Fslim-3-demo-app/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263790971,"owners_count":23512069,"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":[],"created_at":"2024-11-15T00:13:13.293Z","updated_at":"2025-07-05T19:05:01.720Z","avatar_url":"https://github.com/devsavage.png","language":"HTML","readme":"# Slim 3 Demo App\n## If you are looking for a Slim 3 starter app w/ authentication, please see my [Slim-3-Authentication](https://github.com/savageboy74/slim-3-authentication) repo! This project will have more features but won't be updated as often.\nWell, basically this project is a basic Slim 3 application with authentication.   \nI am using Eloquent ORM for the database implementation. You can read more about Eloquent ORM [here](https://laravel.com/docs/master/eloquent).  \nI will continue to add more features as I see fit, soon.\n\n\n## Current and Planned Features\n| Feature        | Description           | Status  |\n| ------------- |:-------------:| -----:|\n| CSRF Protection      | Cross-Site Request Forgery protection. | Feature Complete |\n| Authentication      | A fully featured authentication system. | Feature Complete |\n| Direct Messaging      | A simple way to message other users. | In Progress |\n\n## Installation\nYou will need to use [Composer](https://getcomposer.org/) as well as PHP 5.5 or newer.  \nThen run the following in the folder **composer.json** is located.\n```bash\n$ composer install\n```\n+ This will install all of the required dependencies as well as autoload the other necessary files.  \n+ You will need to update the config file to suit your needs.  You can find the config file in **config/container.config.php**  \n+ You will also need to create the databases. After you setup your database info in the config, you can run the SQL files in the sql folder.  \n+ Once your database is set up, you can register for an account on the site.  \n+ You will manually need to give yourself administrator privileges by using a database manager, such as phpMyAdmin, and updating: **permissions-\u003eis_head_admin** and set it to **1**.  \n\n## Configurartion\nHere is an example configuration file. You will want to place this file in a **config** folder as a php file. I recommend naming it **container.config.php** so you won't need to update anything in the bootstrap file.  \nYou will need to update **app/bootstrap.php** with the location to your config file within the instantiation of the **Slim/App** class.  \n\n```php\n\u003c?php\n\nreturn [\n    'settings' =\u003e [\n      'displayErrorDetails' =\u003e true,\n      'viewTemplatesDirectory' =\u003e '../resources/views',\n      'mysql' =\u003e [\n        'driver' =\u003e 'mysql',\n        'host' =\u003e '127.0.0.1',\n        'username' =\u003e 'root',\n        'password' =\u003e '',\n        'database' =\u003e 'demoapp',\n        'charset' =\u003e 'utf8',\n        'collation' =\u003e 'utf8_unicode_ci',\n      ],\n      'auth' =\u003e [\n        'session' =\u003e 'user_id',\n        'remember' =\u003e 'REM_TOKEN',\n      ],\n      'url' =\u003e 'http://127.0.0.1/demoapp/public',\n    ],\n\n    'user' =\u003e function() {\n      return new \\Savage\\Http\\Auth\\User;\n    },\n\n    'directMessage' =\u003e function() {\n      return new \\Savage\\Http\\Auth\\User\\UserDirectMessages;\n    },\n\n    'directMessageResponse' =\u003e function() {\n      return new \\Savage\\Http\\Auth\\User\\UserDiretMessageResponses;\n    },\n\n    'util' =\u003e function() {\n      return new \\Savage\\Http\\Util\\Utils;\n    },\n\n    'flash' =\u003e function() {\n      return new \\Slim\\Flash\\Messages;\n    },\n\n    'search' =\u003e function() {\n\t\t// Application ID \u0026 Admin API Key\n        return new \\AlgoliaSearch\\Client(\"••••••••••\", \"••••••••••••••••••••••••••••••••\");\n    },\n\n    'view' =\u003e function($c) {\n      $view = new \\Slim\\Views\\Twig($c['settings']['viewTemplatesDirectory'], [\n          'debug' =\u003e true,\n      ]);\n\n      $view-\u003eaddExtension(new \\Slim\\Views\\TwigExtension(\n        $c['router'],\n        $c['request']-\u003egetUri()\n      ));\n\n      $view-\u003eaddExtension(new \\Savage\\Extension\\TwigExtension);\n      $view-\u003eaddExtension(new \\Twig_Extension_Debug());\n\n      $view-\u003egetEnvironment()-\u003eaddGlobal('flash', $c['flash']);\n\n      return $view;\n    },\n\n    'db' =\u003e function($c) {\n      $capsule = new Illuminate\\Database\\Capsule\\Manager;\n\n      $capsule-\u003eaddConnection([\n        'driver' =\u003e $c['settings']['mysql']['driver'],\n        'host' =\u003e $c['settings']['mysql']['host'],\n        'database' =\u003e $c['settings']['mysql']['database'],\n        'username' =\u003e $c['settings']['mysql']['username'],\n        'password' =\u003e $c['settings']['mysql']['password'],\n        'charset' =\u003e $c['settings']['mysql']['charset'],\n        'collation' =\u003e $c['settings']['mysql']['collation']\n      ], 'default');\n\n      return $capsule;\n    },\n\n    //Error Handling\n    'notAllowedHandler' =\u003e function($c) {\n        return function ($request, $response, $methods) use ($c) {\n            return $c['response']\n                -\u003ewithStatus(405)-\u003ewithRedirect($c['router']-\u003epathFor('home'));\n        };\n    },\n\t// If you are in a development environment, I recommend disabling this\n    'errorHandler' =\u003e function($c) {\n\t    return function ($request, $response, $methods) use ($c) {\n            return $c['response']-\u003ewithStatus(500)-\u003ewithHeader('Content-Type', 'text/html')-\u003ewrite('Something went wrong!');\n        };\n    },\n\n    'notFoundHandler' =\u003e function($c) {\n        return function ($request, $response) use ($c) {\n            return $c['response']\n                -\u003ewithStatus(404)\n                -\u003ewithHeader('Content-Type', 'text/html')\n                -\u003ewrite(str_replace($c['settings']['url'], '', $request-\u003egetUri()) . \" was not found on this server.\");\n        };\n    },\n\n    'csrf' =\u003e function($c) {\n        $guard = new \\Slim\\Csrf\\Guard();\n\n        $guard-\u003esetFailureCallable(function ($request, $response, $next) {\n            $request = $request-\u003ewithAttribute(\"csrf_status\", false);\n            if ($request-\u003egetAttribute('csrf_status') === false) {\n                $data = [\n                    'status' =\u003e 400,\n                    'error' =\u003e 'Bad Request',\n                    'message' =\u003e \"Failed CSRF Check\"\n                ];\n\n                return $response-\u003ewithStatus(400)-\u003ewithHeader('Content-Type', 'application/json')-\u003ewrite(json_encode($data));\n            } else {\n                return $next($request, $response);\n            }\n        });\n\n        return $guard;\n    }\n];\n```\n\n## Framework\nHere is a list of most of the packages that make this app work.\n+ [Slim](https://packagist.org/packages/slim/slim)\n    - 3.0\n   - PHP micro framework. The complete inner-workings of the site.\n+ [Slim/Flash](https://packagist.org/packages/slim/flash)\n    - 0.1.0\n    - Extension to Slim. This allows us to show messages until we refresh a page.\n    - I use a slightly modified version of this so I can flash message now for the current request. See [this](https://github.com/slimphp/Slim-Flash/pull/14) for more details.  \n+ [Slim/CSRF](http://assemble.io)\n    - 0.6.0\n    - Extension to Slim. This allows us to implement Cross-Site Request Forgery protection.\n+ [Twig](https://packagist.org/packages/slim/csrf)\n    - 1.18\n    - Template Engine\n+ [Slim/Twig-View](https://packagist.org/packages/slim/twig-view)\n    - 2.0\n    - This is Slim's extension of Twig (See above)\n+ [Illuminate/Database (Eloquent ORM)](https://packagist.org/packages/illuminate/database)\n    - 5.2\n    - This handles all of our database queries and such.\n+ [Carbon](https://packagist.org/packages/nesbot/carbon)\n    - 1.21\n    - A simple PHP API extension for DateTime.\n+ [Violin](https://packagist.org/packages/alexgarrett/violin)\n    - 2.2.2\n    - This is how we validate all data in our forms.\n+ [RandomLib](https://packagist.org/packages/ircmaxell/random-lib)\n    - 1.1\n    - A library for generating random numbers and strings of various strengths.\n+ [Algolia](https://packagist.org/packages/algolia/algoliasearch-client-php)\n\t- 1.7\n\t- A search API\n\n\n## License\nThis work is licensed under the MIT license. See [License File](LICENSE) for more information.\n\n## Other\nIf you feel this project would suit your needs, feel free to use any or all of the code I have provided.  \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsavage%2Fslim-3-demo-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevsavage%2Fslim-3-demo-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsavage%2Fslim-3-demo-app/lists"}