Welcome to my API app made with Apiato (Laravel). I am trying to create a sample as a quick start to any robust ReactJs web app. I chose Apiato as the main framework to work on because it offers a well-organized and simple-to-read software architecture pattern named Porto.
For this part of the project, I configured Apiato and created a container named SampleForm. It holds all the business logic to be consumed with my other initial project sample_form_react to give power to easier consume APIS which allows it to perform a CRUD operation.
This project is meant to be used with the Laradock framework. It creates the necessary dockers such as PostgreSQL, Nginx, and PHP-fpm as the initial development environment.
The same as Laradock requirements:
https://laradock.io/getting-started/#requirements
- Clone the following repositories in the same directory:
git clone git@github.com:bos21001/sample_form_integration.git
git clone https://github.com/Laradock/laradock.git
- Copy the the
.env
anddefault.conf
from sample_form_integration directory to laradock directory:
cp sample_form_integration/laradock/.env.example laradock/.env && cp sample_form_integration/laradock/nginx/sites/default.conf laradock/nginx/sites/default.conf
- Go to laradock directory:
cd laradock/
- Build and initialize the following dockers from laradock:
docker-compose build nginx php-fpm workspace postgres && docker-compose up -d nginx php-fpm workspace postgres
- Find and copy the ipaddress setted to your postgres docker:
docker inspect laradock_postgres_1
- Edit your hosts file:
sudo nano /etc/hosts
- Paste the following in the last line:
127.0.0.1 sample-form.local api.sample-form.local admin.sample-form.local\
[paste your postgres ipAddress here] db.sample-form.local
- Make sure to execute all the following commands within the workspace container generated with laradock. Use the following command to acces this container:
docker-compose exec --user=laradock workspace bash
- Go to sample_form_integration directory and copy
.env-example
in the root directory renaming it to.env
:
cd sample_form_integration/
cp .env.example .env
- Install all composer and npm dependencies:
composer install
npm install
- Create your KEY_APP:
php artisan key:generate
- Set the database:
php artisan migrate
php artisan db:seed
This will generate all the tables and will create an admin user with the following credentials:
email: admin@admin.com
password: admin
- Install passport and add the generated keys to your
.env
file:
php artisan passport:install
Copy the second
Client ID
generated and paste inCLIENT_WEB_ID
in the.env
file: Copy theClient Secret
of theClient ID
you copied and paste inCLIENT_WEB_SECRET
- Finally Create the documentations of the API endpoints with ApiDocJs using the artisan command:
php artisan apiato:apidoc
- (Optional): Follow the Getting Started of sample_form_react which consume these APIs properly.
This project uses PostgreSQL as the Relational Database
It has only one database and make use of the following tables that are generated by the laravel migrations:
- sample_forms
- oauth_auth_codes
- users
- failed_jobs
- migrations
- model_has_permissions
- model_has_roles
- notifications
- oauth_access_tokens
- oauth_clients
- oauth_personal_access_clients
- oauth_refresh_tokens
- password_resets
- permissions
- role_has_permissions
- roles
- Frameworks:
- Apiato v11
- Laravel v9
- Laradock
- Libraries:
- ApiDocJs
- Create relational tables were users have sample-forms
- Create a home view instead of Apiato home page
Thanks to André Bellafronte who taught me those principles, and presented me Apiato, Laradock and its tools!