This backend provides an API for dealing with the database information. It uses Passport, which is an OAuth2 and authentication package.
The OAuth 2.0 Authorization Framework, defined in the RFC-6749, provides authorization control for all kinds of applications, wether they may be web or desktop based.
In order to test locally firstly you'll need to have a working web server and database.
- Configuring the .env file. You may use the same configuration from Deployment but you must change the following variables as follows:
APP_ENV=development
APP_DEBUG=true
...
- Install Passport.
php artisan passport:install
- If after the install you don't have any keys stored in the .env file under the
APP_KEY
variable, you must run:
php artisan key:generate
- Run the migrations.
php artisan migrate
- Running the live server.
- Use the command
php artisan serve
- On a new terminal execute
php artisan queue:work --queue=email
- Initialize the Websocket server
php artisan websocket:init
Or, in short:
php artisan serve
php artisan serve --host=my.local.network.serverIp --port=8000
php artisan queue:work --queue=email
php artisan websocket:init
This guide takes into account that the web server has been previously configured. To successfully deploy this backend, you must:
- Properly configure the .env file.
APP_ENV=production
APP_DEBUG=false
...
APP_URL=https://...
...
DB_CONNECTION=... <- wether it is mysql or other DB
DB_HOST=... <- host (IP) in charge of the DB
DB_PORT=...
DB_DATABASE=... <- name of the DB
DB_USERNAME=...
DB_PASSWORD=...
...
QUEUE_CONNECTION=database
...
MAIL_DRIVER=smtp
MAIL_HOST=...
MAIL_PORT=...
MAIL_USERNAME=... <- email account
MAIL_PASSWORD=...
MAIL_ENCRYPTION=... <- SSL/TLS/STARTTLS...
MAIL_FROM_ADDRESS=... <- email account
MAIL_FROM_NAME="${APP_NAME}"
...
- Generate application keys.
php artisan key:generate
- Install Passport.
php artisan passport:install
- Migrate the database.
php artisan migrate --force
- Optimize autoloader.
composer install --optimize-autoloader --no-dev
- Optimize configurations.
php artisan config:cache
- Optimize API routes.
php artisan route:cache
- Precompile views.
php artisan view:cache
- Install & configure supervisor. This will take care of the queued jobs such as email sending and the websocket for the realtime chat.
- Ready to go!
Laravel is a web application framework with expressive, elegant syntax. The authors believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects.
More info: Laravel website.
npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently.
It is extremely configurable to support a wide variety of use cases. Most commonly, it is used to publish, discover, install, and develop node programs.
Discover more at the NPM site.
This work is copyrighted by Luis Miguel Soto Sánchez and thus, cannot be distributed or copied in any way unless strictly told by the author.