Prerequisites
= install docker [link]
= install composer
= install docker-compose
sudo apt install docker-compose
Get up and running
curl -s https://laravel.build/<your_app_name> | bash
If you want to build laravel only with certain services, run:
curl -s https://laravel.build/<your_app_name>?with=mysql | bash
Before starting laravel, stop running services
sudo service nginx stop && sudo service mysql stop
Then go to app folder
cd <your_app_name>
Let laravel run:
./vendor/bin/sail up
Access your app from browser: localhost:80
What now?
In project root folder is now available file docker-compose.yml
If you like to add phpmyadmin to your project, stop containers:
docker down
To add phpmyadmin configure docker-compose.yml like this [link]
Run sail up again, this time with phpmyadmin container:
./vendor/bin/sail up
If you like, define alias:
alias sail='bash vendor/bin/sail'
Use commands like:
sail artisan migrate
Hands on!
Create your own blade template home.blade.php and add bootstrap starter template to it [link]
Configure routing in web.php
Route::get('/', function () {
return view('home');
});
Make your first data model, controller and migration:
sail artisan make:model Thing -crm
Configure migration file:
$table->text('name');
And make migration:
sail artisan migrate
Basic routing > controller > view
Customize routing > controller > view
Routing:
Route::get('/', [ThingController::class, 'index'])->name('get_home');
Controller:
public function index()
{
return view('container');
}
View:
Whatever you have there…
To create your model Thing
Routing:
Route::post('/thing', [ThingController::class, 'store'])->name('store_thing');
Controller:
public function store(Request $request)
{
$thing = Thing::create([
'name' => $request->name
]);
return redirect()->route('get_home');
}
View:
<form class="" action="{{route('store_thing')}}" method="post">
<div class="form-group">
@csrf
<label for="name" class="form-label">Thing</label>
<input type="text" name="name" id="name" autocomplete="" class="form-control" value="" autofocus="autofocus">
<small id="emailHelp" class="form-text text-muted">Enter something...</small>
<button type="submit" class="btn btn-primary" name="enter_name">Sisesta</button>
</div>
</form>