Example Laravel codebase containing real world examples (CRUD, auth, advanced patterns and more) that adheres to the Travel_Agency spec and API.
This repo is functionality complete — PRs and issues welcome!
Please check the official laravel installation guide for server requirements before you start. Official Documentation
Alternative installation is possible without local dependencies relying on Docker.
Clone the repository
git clone https://github.com/AmjadGhzlangit/Travel_Agency.git
Switch to the repo folder
cd Travel_Agency
Install all the dependencies using composer
composer install
Copy the example env file and make the required configuration changes in the .env file
cp .env.example .env
Generate a new application key
php artisan key:generate
Run the database migrations (Set the database connection in .env before migrating)
php artisan migrate
Start the local development server
php artisan serve
You can now access the server at http://localhost:8000
TL;DR command list
git clone https://github.com/AmjadGhzlangit/Travel_Agency.git
cd Travel_Agency
composer install
cp .env.example .env
php artisan key:generate
php artisan jwt:generate
Make sure you set the correct database connection information before running the migrations Environment variables
php artisan migrate
php artisan serve
Populate the database with seed data with relationships which includes users, articles, comments, tags, favorites and follows. This can help you to quickly start testing the api or couple a frontend and start using it with ready content.
Run the database seeder and you're done
php artisan db:seed
Note : You can create the first admin by running the following command
php artisan user:create
To install with Docker, run following commands:
git clone https://github.com/AmjadGhzlangit/Travel_Agency.git
cd Travel_Agency
cp .env.example.docker .env
docker run -v $(pwd):/app composer install
cd ./docker
docker-compose up -d
docker-compose exec php php artisan key:generate
docker-compose exec php php artisan migrate
docker-compose exec php php artisan db:seed
docker-compose exec php php artisan serve --host=0.0.0.0
The api can be accessed at http://localhost:8000/api.
This application adheres to the api specifications set by the Thinkster team. This helps mix and match any backend with any other frontend without conflicts.
More information regarding the project can be found here https://github.com/gothinkster/realworld
app
- Contains all the Eloquent modelsapp/Http/Controllers/Api
- Contains all the api controllersapp/Http/Middleware
- Contains the JWT auth middlewareapp/Http/Requests/Api
- Contains all the api form requestsapp/RealWorld/Favorite
- Contains the files implementing the favorite featureapp/RealWorld/Filters
- Contains the query filters used for filtering api requestsapp/RealWorld/Follow
- Contains the files implementing the follow featureapp/RealWorld/Paginate
- Contains the pagination class used to paginate the resultapp/RealWorld/Slug
- Contains the files implementing slugs to articlesapp/RealWorld/Transformers
- Contains all the data transformersconfig
- Contains all the application configuration filesdatabase/factories
- Contains the model factory for all the modelsdatabase/migrations
- Contains all the database migrationsdatabase/seeds
- Contains the database seederroutes
- Contains all the api routes defined in api.php filetests
- Contains all the application teststests/Feature/Api
- Contains all the api tests
.env
- Environment variables can be set in this file
Note : You can quickly set the database information and other variables in this file and have the application fully working.
Run the laravel development server
php artisan serve
The api can now be accessed at
http://localhost:8000/api/v1
Request headers
Required | Key | Value |
---|---|---|
Yes | Content-Type | application/json |
Yes | X-Requested-With | XMLHttpRequest |
Optional | Authorization | Bearer Token |
Refer the api specification for more info.