This skeleton is a fork and contain ideas from those repos:
- https://github.com/geraudi/slim-react-skeleton
- https://github.com/shameerc/slim-skeleton
- https://github.com/akrabat/slim3-skeleton
The whole application interface is described in this OpenAPI document. There is no manual routes coding. Just a Json or Yaml file that describes how either frontend and the API should behave. The component Swagger-Dispatcher will take care of automatically building all the routes needed. Of course, because of dependency injection, you'll have to inject all the Command Handlers.
composer install
Installation :
Please consider that the host is hard-coded in a couple of parts of the code. Corrently the value is sampleapp.local, you should need to update this value to the one used by you. Its planned to parametrize it in a way that could be used the host specified in the swagger file.
npm install
Run webpack dev server :
npm run start
Run test :
vendor/bin/phpunit tests
##Config
###app/config/settings.php
Please create a DB. In order to test our application, import the sql file The add the parameters of the db to app/config/settings.php
...
'pdo' => [
'dns' => 'mysql:dbname=my-db;host=127.0.0.1;charset=utf8',
'user' => 'root',
'password' => 'root'
],
...
...
'auth' => [
'jwtKey' => '1234567890ABCDEF', // <= Change here
'requestAttribute' => 'jwt',
'relaxed' => ["localhost", "127.0.0.1", "sampleapp.local",] ,
'path' => [ "/items"],
'passthrough' => ["/", "/auth", "/api/v1/auth"],
]
...
- By default, we request a secure connection, during development you'll have to add your url to the relaxed key.
- All the routes that require the user to be authenticated, must be added to path
- All the routes that may be called without a secure token(generated after authentication), must be added to passthrough
####src/js/lib/api.js
...
axios.defaults.baseURL = 'http://example.com/api/v1/';
...