Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
Laravel is accessible, powerful, and provides tools required for large, robust applications.
Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.
If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [email protected]. All security vulnerabilities will be promptly addressed.
The Laravel framework is open-sourced software licensed under the MIT license.
cd your parent_folder_path
#con laravel installer
laravel new your_project_name_here
#per versione 9
composer create-project --prefer-dist laravel/laravel:^9.2 your_project_name_here
cd your_project_name_here
code . -r
php artisan serve
ctrl + c
npm remove postcss
#installo dbal per migration e seeder
composer require doctrine/dbal
composer require guzzlehttp/guzzle
composer require laravel/breeze --dev
php artisan breeze:install #blade
composer require pacificdev/laravel_9_preset
#solo per versione 9yes
php artisan preset:ui bootstrap --auth
npm install bootstrap axios @fortawesome/fontawesome-free sass
npm install axios @fortawesome/fontawesome-free sass
#in vite config aggiungo agli alias
'~@fortawesome': path.resolve(__dirname, 'node_modules/@fortawesome'),
#copio la cartella dei webfont e se voglio la rinomino e la copio nella cartella font
#app.js
import "./bootstrap";
import "~resources/scss/app.scss";
import * as bootstrap from "bootstrap";
import.meta.glob(["../img/**", "../fonts/**"]);
#app.scss
@use './partials/variables' as *;
$fa-font-path: "../fonts/webfonts" !default;
@import "~@fortawesome/fontawesome-free/scss/fontawesome";
@import "~@fortawesome/fontawesome-free/scss/regular";
@import "~@fortawesome/fontawesome-free/scss/solid";
@import "~@fortawesome/fontawesome-free/scss/brands";
@import '~bootstrap/scss/bootstrap';
h1 {
color: $text-color;
}
#vite.config.js
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import * as path from "path";
export default defineConfig({
plugins: [
laravel({
input: ["resources/scss/app.scss", "resources/js/app.js"],
refresh: true,
}),
],
// Add resolve object and aliases
resolve: {
alias: {
"~bootstrap": path.resolve(__dirname, "node_modules/bootstrap"),
"~@fortawesome": path.resolve(
__dirname,
"node_modules/@fortawesome"
),
"~resources": "/resources/",
},
},
});
#sistemo (cambio/rimuovo) template e routing
#volendo personalizzo paginazione e pagine di errore
php artisan vendor:publish --tag=laravel-errors
php artisan vendor:publish --tag=laravel-pagination
#comandi git
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin your_git_url
git push -u origin main
# copio file .env.example e lo rinomino in .env
composer install
php artisan key:generate
npm install
# creo il database da phpmyadmin
# inserisco i dati per il collegamento al db in env
#creo migration
php artisan make:migration create_nome_tabella_table
php artisan make:migration update_users_table --table=users
php artisan make:migration add_phone_number_to_users_table
#lanciare migration
php artisan migrate
#revert migration
php artisan migrate:rollback
#popolare il db
php artisan make:seeder UsersTableSeeder
php artisan db:seed --class=UsersTableSeeder
# preparo le rotte file web.php es.
Route::get('/books', [BookController::class, 'index'])->name('books.index');
# oppure resource route per tutte le operazioni CRUD
Route::resource('books', BookController::class);
# creo controller
php artisan make:controller NomeController
#con opzione resource controller
php artisan make:controller NomeController --resource
#creo model
php artisan make:model Nome
#posso creare il model e contestualmente resource controller, migration, seeder e form request per validazioni
php artisan make:model Nome -rcms --requests
# creo le views relative
#creo form request per validazione
php artisan make:request StoreMomemodelRequest
#in app/Providers/RouteServiceProvider.php modifico
public const HOME = '/admin';
# Se l’utente non è autenticato, sarà dirottato automaticamente verso la pagina di login.
# Questo comportamento è modificabile nel file in app/Http/Middleware/Authenticate.php
php artisan make:controller Admin/DashboardController
# nel controller
public function index(){
return view('admin.dashboard');
}
Route::middleware(['auth', 'verified'])
->name('admin.')
->prefix('admin')
->group(function () {
Route::get('/', [DashboardController::class, 'index'])
->name('dashboard');
});
....
Route::fallback(function() {
return redirect()->route('admin.dashboard');
});
#installazione
php artisan make:livewire Nome_componente
#inserimento componente in pagina blade (2 opzioni)
@livewire('nomecomponente')
<livewire:nomecomponente/>