PHP Classes

How to Setup a Laravel Project Docker Container Learning from the Package Laravel Simple Docker: Run example Laravel API application using Docker

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-01-17 (8 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 9 This week: 9All time: 11,504 This week: 5Up
Version License PHP version Categories
laravel-simple-docke 1.0The PHP License5PHP 5, Web services, Geography, Appli...
Description 

Author

This package can run an example Laravel API application using Docker.

It provides an API application that implements services to find locations and routes between locations.

The package provides scripts to install the application in a Docker container.

Picture of Hicri
  Performance   Level  
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

 

Example

<?php

use App\Http\Controllers\LocationController;
use
App\Http\Controllers\RoutingController;
use
Illuminate\Http\Request;
use
Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return
$request->user();
});
Route::post('/login',[\App\Http\Controllers\Auth\LoginController::class, 'login'])->name('login');

Route::group(['middleware' => 'auth:api'], function ($router) {

   
Route::post('/register',[\App\Http\Controllers\Auth\RegisterController::class, 'store']);
   
Route::post('/logout',[\App\Http\Controllers\Auth\LogoutController::class, 'logout']);
   
Route::post('/refresh',[\App\Http\Controllers\Auth\LoginController::class, 'refresh']);

   
Route::get('/location', [LocationController::class, 'index'])->middleware('throttle:30,1');
   
Route::post('/location/store', [LocationController::class, 'store'])->middleware('throttle:30,1');
   
Route::get('/location/{id}', [LocationController::class, 'show'])->middleware('throttle:30,1');
   
Route::post('/location/update', [LocationController::class, 'update'])->middleware('throttle:30,1');
   
Route::delete('/location/{location}', [LocationController::class, 'delete'])->middleware('throttle:30,1');

   
Route::get('/routing/{latitude}/{longitude}', [RoutingController::class, 'index'])->middleware('throttle:30,1');
});


Details

Requirements

  • PHP
  • Composer
  • Docker
    ## Installation
    docker compose up -d --build
    docker compose exec app bash
    chmod -R 777 /app/storage/ /app/bootstrap/
    composer install
    docker compose exec app php artisan key:generate
    docker compose exec app php artisan jwt:secret
    docker compose exec app php artisan migrate:fresh --seed
    
  • .env 
    DB_CONNECTION=mysql
    DB_HOST=db
    DB_PORT=3306
    DB_DATABASE=laravel
    DB_USERNAME=laravel
    DB_PASSWORD=laravel
    
    ## Contents
    
    laravel mysql jwt
  • Usage
    request.json
    

  Files folder image Files (96)  
File Role Description
Files folder image.idea (5 files)
Files folder imageapp (5 directories)
Files folder imagebootstrap (1 file)
Files folder imageconfig (16 files)
Files folder imagedatabase (3 directories)
Files folder imagedocker (2 directories)
Files folder imagepublic (3 files)
Files folder imageresources (2 directories)
Files folder imageroutes (4 files)
Files folder imagetests (2 files, 2 directories)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .env.example Data Auxiliary data
Plain text file artisan Class Class source
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file docker-compose.yml Data Auxiliary data
Accessible without login Plain text file Dockerfile Data Auxiliary data
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file request.json Data Auxiliary data
Accessible without login Plain text file vite.config.js Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:9
This week:9
All time:11,504
This week:5Up