Laravel
Beginner
1 min read
Laravel Directory Structure and Artisan CLI
Example
# Make a new Eloquent model with migration, factory, and seeder
php artisan make:model Post -mfs
# Make a resourceful controller
php artisan make:controller PostController --resource --model=Post
# Make a form request for validation
php artisan make:request StorePostRequest
# Make a custom Artisan command
php artisan make:command SendWeeklyDigest
# Make a middleware
php artisan make:middleware EnsureEmailIsVerified
# Make an event and its listener
php artisan make:event OrderPlaced
php artisan make:listener SendOrderConfirmation --event=OrderPlaced
# Open the interactive Tinker REPL
php artisan tinker
# Inside Tinker:
# >>> App\Models\User::count()
# => 5
# >>> App\Models\Post::factory()->create(['title' => 'Hello'])
# Display all registered routes
php artisan route:list
# Cache routes for production
php artisan route:cache
Related Resources
Laravel Reference
Complete tag & property list
Laravel How-To Guides
Step-by-step practical guides
Laravel Exercises
Practice what you've learned
More in Laravel