/webapp.portfolio.example

Laravel with React example application

Primary LanguagePHP

WEBAPP Example

Laravel 8 with React.js 17 web application example.
The Laravel app uses Repository design pattern, API Resource, Form Request Validation and pivot table.

The ReactJS application can be found in /resources/admin/.
It serves as an example to show that I am accustomed with both programming styles: functional based components with hooks and class based components.
Global state is managed by Redux and can be found in /resources/admin/js/stores/.

Installation

Create database:

mysql> create database webappexample;

Copy file .env.example to .env
$ cp .env.example .env
and edit .env file based on your settings:
- database: DB_USERNAME, DB_PASSWORD
- main user: ADMIN_CREDENTIALS_EMAIL; ADMIN_CREDENTIALS_PASSWD


Copy the virtual host file from /debian/ to your apache directory.
$ cp -fr debian/webapp.portfolio.localhost.conf /etc/apache2/sites-available/
Change file /etc/apache2/sites-available/webapp.portfolio.localhost.conf with your paths.

Activate the virtual host and reload apache:
$ sudo a2ensite webapp.portfolio.localhost.conf
$ sudo systemctl reload apache2
Apache mod_rewrite must be enabled ($ sudo a2enmod rewrite)

Add the following line to your /etc/hosts:
127.0.1.1	webapp.portfolio.localhost

Install dependencies using composer:
$ composer install

Run DB migration:
$ php artisan migrate

Create a Password Grant Client:
$ php artisan passport:client --password

What should we name the password grant client? [WEBAPP-Portfolio-Example Password Grant Client]:

password

Which user provider should this client use to retrieve users? [users]: [0] users

Password grant client created successfully.

Edit .env with the generated ID and secret:

MIX_ADMIN_CLIENT_ID=---Client ID-here---
MIX_ADMIN_CLIENT_SECRET="---Client secret-here---"

Install front-end dependencies:
$ npm install

Generate a production build:
$ npm run prod