# Laravel
Full stack framework and tooling for modern PHP.
## Pre-reqs
- [[PHP]]
- [[Composer for PHP]]
- NodeJS
- npm
- ...
## Installation
It's possible to install Laravel globally using [[Composer for PHP|composer]]: `composer global require laravel/installer`. But it's probably not ideal (easy to use an outdated version?).
Instead, you can create a project using
## Commands
The CLI of Laravel is called [[Laravel Artisan|Artisan]]. Here are a few useful commands:
- `php artisan serve`: Start the app
- `php artisan route:list`: List API routes
## Logging
Laravel has built-in support for logging: https://laravel.com/docs/11.x/logging
`use Illuminate\Support\Facades\Log::info("Hello there");`
For pure debugging, you can also use the `dd` utility function: https://shouts.dev/articles/laravel-dd-vs-dump-vs-vardump-vs-printr-with-example
## Database migrations
Laravel has built-in support for database migrations: https://laravel.com/docs/11.x/migrations
To create those, you can use `php artisan make:migration description_of_the_change`. Migration files are put under `database/migrations`. Each migration file is a PHP script with a `up` and `down` function. The `up` function modifies the database, moving forward, while the `down` method reverts the change, if a rollback is needed. Inside of those functions, you can use the `Schema` class to create or drop tables, add indexes, etc.
Here's an example:
```
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations. */ public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('cuid');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->string('profile_photo_path', 2048)->nullable();
$table->timestamps();
});
...
}
/**
* Reverse the migrations. */ public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
}
};
```
It's also possible to update existing rows using the `DB` class, as explained here: https://benjaminlistwon.com/blog/in-brief-002-updating-rows-in-a-migration.
## References
- Website: https://laravel.com/
- Documentation: https://laravel.com/docs/11.x/horizon
- Courses and tutorials: https://laracasts.com
- Bootcamp: https://bootcamp.laravel.com/
- Packages list: https://packalyst.com/
- State of Laravel: https://stateoflaravel.com/
- X: https://x.com/laravelphp
## Community
* [Laracasts Forum](https://laracasts.com/discuss)
* [Laravel.io Forum](http://laravel.io/forum)
* [Larachat Slack](https://larachat.slack.com/) ([Signup](https://larachat.co/register))
* [Gitter](https://gitter.im/laravel/laravel)
* [IRC Channel](http://laravel.io/chat)
* [StackOverflow](http://stackoverflow.com/questions/tagged/laravel)
* [Twitter](https://x.com/laravelphp)
* [Google+](https://plus.google.com/communities/106838454910116161868)
* [Reddit](https://www.reddit.com/r/laravel)
* [Quora](https://www.quora.com/topic/Laravel)
* [Facebook](https://www.facebook.com/LaravelCommunity)
* [LinkedIn](https://www.linkedin.com/groups/4419933/profile)
## Related
<!-- QueryToSerialize: LIST FROM #software_development/php/frameworks/laravel WHERE public_note = true SORT file.name ASC -->
<!-- SerializedQuery: LIST FROM #software_development/php/frameworks/laravel WHERE public_note = true SORT file.name ASC -->
- [[Blade]]
- [[How to add Laravel support to IntelliJ Idea]]
- [[How to add security headers to Laravel applications]]
- [[How to create a Laravel application with Jetstream, Inertia, Vue.js, and TypeScript]]
- [[How to create a Laravel project]]
- [[How to debug PHP and Laravel applications with IntelliJ]]
- [[How to develop Laravel apps in IntelliJ]]
- [[How to install Valet on Ubuntu]]
- [[Laraval API naming conventions]]
- [[Laravel]]
- [[Laravel Artisan]]
- [[Laravel Auditing]]
- [[Laravel Echo]]
- [[Laravel Forge]]
- [[Laravel Fortify]]
- [[Laravel Inertia]]
- [[Laravel Jetstream]]
- [[Laravel OpenAPI]]
- [[Laravel Reverb]]
- [[Laravel Sail]]
- [[Laravel Socialite]]
- [[Laravel WebSockets]]
- [[Livewire]]
- [[Ploi]]
- [[Valet]]
<!-- SerializedQuery END -->