Thanks to visit codestin.com
Credit goes to github.com

Skip to content

karolski/Slim-PHP-Basic-Chat-Backend-Example

Repository files navigation

Example chat application

Run in Postman

Documentation here

This backend uses two entities: Message and User. It uses:

  • SQLite database - in var folder (after setting up)
  • JWT as authentication mechanism using RSA256
  • Doctrine for ORM and DB access layer
  • Follows Action-Service-Repository-Entity pattern
  • PSR1 standard
  • Static analysis with PHPStan and PHP_CodeSniffer
Configuration: JWT_SECRET in env, see .env for example

For your convinience you can obtain all tokens (signed with development private key) at /testing/get-jwt-tokens or by running php commands/getTestJwtTokens.php after setup. The tokens will work for 10 minutes, provided you will not change the default JWT_SECRET in .env

One line run

docker-compose up
  • in case you run it on a mac, you may need to replace .env with .env.mac for docker-compose whitespace errors

Local setup

composer install
sh setup_db.sh

To run the application in development

composer start

Test

composer test
composer test:coverage
composer analyse
composer sniff
composer sniff:fix
  • you might need to install xdebug. For ubuntu sudo apt install php-xdebug

Disclaimers

  • The application does not enforce https, so you can test it locally.
  • the listing APIs don't use pagination - for the sake of simplicity. In case there would be long conversations or thousands of users, it would be appropriate to use pagination.

©2020 Karol Skalski

About

Slim framework basic backend setup

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages