๐Ÿš€ Laravel Cheat Sheet - Najwaลผniejsze Polecenia

๐Ÿ“ฆ Artisan - Podstawowe

php artisan list # Lista wszystkich poleceล„ php artisan help <command> # Pomoc dla polecenia php artisan tinker # Interaktywny shell php artisan down # Tryb maintenance php artisan up # Wyล‚ฤ…cz maintenance

๐Ÿ—„๏ธ Migracje

php artisan make:migration create_users_table # Nowa migracja php artisan migrate # Uruchom migracje php artisan migrate:rollback # Cofnij ostatniฤ… php artisan migrate:rollback --step=3 # Cofnij 3 ostatnie php artisan migrate:reset # Cofnij wszystkie php artisan migrate:refresh # Reset + migracja php artisan migrate:fresh # Drop tabele + migracja php artisan migrate:status # Status migracji

๐ŸŒฑ Seeders

php artisan make:seeder UserSeeder # Nowy seeder php artisan db:seed # Uruchom wszystkie php artisan db:seed --class=UserSeeder # Konkretny seeder php artisan migrate:refresh --seed # Migracja + seeding

๐Ÿญ Factories

php artisan make:factory UserFactory # Nowa factory php artisan make:factory UserFactory --model=User # Z modelem

๐Ÿ“Š Modele

php artisan make:model User # Tylko model php artisan make:model User -m # + migracja php artisan make:model User -f # + factory php artisan make:model User -s # + seeder php artisan make:model User -c # + controller php artisan make:model User -mfsc # Kombinacja php artisan make:model User -a # Wszystko

๐ŸŽฎ Kontrolery

php artisan make:controller UserController # Zwykล‚y controller php artisan make:controller UserController --resource # Resource controller php artisan make:controller UserController --api # API controller php artisan make:controller UserController --model=User # Z modelem

๐Ÿ›ฃ๏ธ Routing

php artisan route:list # Wszystkie trasy php artisan route:list --compact # Kompaktowa lista php artisan route:list --name=user # Filtr po nazwie php artisan route:cache # Cache tras php artisan route:clear # Wyczyล›ฤ‡ cache tras

๐Ÿ” Middleware

php artisan make:middleware CheckAge # Nowy middleware php artisan make:middleware CheckAge --test # Z testem

๐Ÿ“ Requests

php artisan make:request StoreUserRequest php artisan make:request UpdateUserRequest

๐ŸŽจ Views & Components

php artisan make:component Button php artisan make:component Button --inline php artisan view:cache php artisan view:clear

๐Ÿ“ง Mailable

php artisan make:mail WelcomeEmail php artisan make:mail WelcomeEmail --markdown=emails.welcome

๐Ÿ”” Notifications

php artisan make:notification UserRegistered php artisan notifications:table

๐Ÿ—ƒ๏ธ Resources (API)

php artisan make:resource UserResource php artisan make:resource UserCollection php artisan make:resource User --collection

๐Ÿ“‹ Jobs (Kolejki)

php artisan make:job ProcessPayment php artisan queue:work php artisan queue:work --once php artisan queue:work --timeout=60 php artisan queue:listen php artisan queue:restart php artisan queue:failed php artisan queue:retry all php artisan queue:flush php artisan queue:table

๐Ÿ“… Scheduler

php artisan schedule:run php artisan schedule:list

๐Ÿ”ง Cache

php artisan cache:clear php artisan cache:forget <key> php artisan cache:table

โš™๏ธ Config

php artisan config:cache php artisan config:clear php artisan config:show

๐Ÿ”‘ Key & Storage

php artisan key:generate php artisan storage:link

๐Ÿงน Optymalizacja

php artisan optimize php artisan optimize:clear php artisan clear-compiled

๐Ÿงช Testy

php artisan make:test UserTest php artisan make:test UserTest --unit php artisan test php artisan test --filter=UserTest

๐ŸŽจ Laravel Themer

php artisan theme:create ThemeName php artisan theme:list php artisan theme:use ThemeName php artisan theme:publish php artisan theme:clear

๐Ÿ“ฆ Laravel Modules - Zarzฤ…dzanie

php artisan module:make Blog php artisan module:make Blog --plain php artisan module:list php artisan module:enable Blog php artisan module:disable Blog php artisan module:delete Blog php artisan module:use Blog php artisan module:unuse

๐Ÿ“ฆ Modules - Generowanie

php artisan module:make-controller BlogController Blog php artisan module:make-model Post Blog php artisan module:make-migration create_posts_table Blog php artisan module:make-seed PostsTableSeeder Blog php artisan module:make-factory PostFactory Blog php artisan module:make-middleware CheckBlogAccess Blog php artisan module:make-request CreatePostRequest Blog php artisan module:make-resource PostResource Blog php artisan module:make-job PublishPost Blog php artisan module:make-event PostCreated Blog php artisan module:make-listener SendPostNotification Blog php artisan module:make-notification PostPublished Blog php artisan module:make-policy PostPolicy Blog php artisan module:make-rule ValidPostStatus Blog php artisan module:make-command SendNewsletterCommand Blog php artisan module:make-mail PostPublishedMail Blog php artisan module:make-provider CustomServiceProvider Blog php artisan module:make-test PostTest Blog

๐Ÿ“ฆ Modules - Migracje

php artisan module:migrate php artisan module:migrate Blog php artisan module:migrate-rollback Blog php artisan module:migrate-reset Blog php artisan module:migrate-refresh Blog php artisan module:migrate-status Blog php artisan module:seed php artisan module:seed Blog

๐Ÿ“ฆ Modules - Publikowanie

php artisan module:publish Blog php artisan module:publish-migration Blog php artisan module:publish-config Blog php artisan module:install Blog

๐Ÿ” Make - Pozostaล‚e

php artisan make:command SendEmails php artisan make:event UserRegistered php artisan make:listener SendWelcomeEmail php artisan make:provider CustomProvider php artisan make:rule Uppercase php artisan make:policy UserPolicy php artisan make:observer UserObserver php artisan make:cast Json php artisan make:channel PushChannel

๐Ÿ› ๏ธ Dodatkowe narzฤ™dzia

php artisan inspire php artisan env php artisan about

๐Ÿ’ก Przydatne kombinacje

php artisan migrate:fresh --seed php artisan optimize:clear php artisan make:model Post -a php artisan route:list --compact php artisan module:make Blog && php artisan module:migrate Blog --seed

๐Ÿ—๏ธ Struktura moduล‚u DDD (Domain Driven Design)

Zalecana struktura katalogรณw dla moduล‚รณw DDD:
Modules/ โ””โ”€โ”€ Blog/ โ”œโ”€โ”€ Config/ โ”‚ โ””โ”€โ”€ config.php โ”œโ”€โ”€ Database/ โ”‚ โ”œโ”€โ”€ Migrations/ โ”‚ โ”œโ”€โ”€ Seeders/ โ”‚ โ””โ”€โ”€ Factories/ โ”œโ”€โ”€ Domain/ # Warstwa domenowa โ”‚ โ”œโ”€โ”€ Entities/ # Encje domenowe โ”‚ โ”‚ โ”œโ”€โ”€ Post.php โ”‚ โ”‚ โ””โ”€โ”€ Category.php โ”‚ โ”œโ”€โ”€ ValueObjects/ # Obiekty wartoล›ci โ”‚ โ”‚ โ”œโ”€โ”€ PostStatus.php โ”‚ โ”‚ โ””โ”€โ”€ Slug.php โ”‚ โ”œโ”€โ”€ Repositories/ # Interfejsy repozytoriรณw โ”‚ โ”‚ โ”œโ”€โ”€ PostRepositoryInterface.php โ”‚ โ”‚ โ””โ”€โ”€ CategoryRepositoryInterface.php โ”‚ โ”œโ”€โ”€ Services/ # Usล‚ugi domenowe โ”‚ โ”‚ โ”œโ”€โ”€ PostService.php โ”‚ โ”‚ โ””โ”€โ”€ SlugGenerator.php โ”‚ โ””โ”€โ”€ Events/ # Eventy domenowe โ”‚ โ”œโ”€โ”€ PostCreated.php โ”‚ โ””โ”€โ”€ PostPublished.php โ”œโ”€โ”€ Application/ # Warstwa aplikacji โ”‚ โ”œโ”€โ”€ Commands/ # Command handlers โ”‚ โ”‚ โ”œโ”€โ”€ CreatePostCommand.php โ”‚ โ”‚ โ””โ”€โ”€ PublishPostCommand.php โ”‚ โ”œโ”€โ”€ Queries/ # Query handlers โ”‚ โ”‚ โ”œโ”€โ”€ GetPostQuery.php โ”‚ โ”‚ โ””โ”€โ”€ GetPostsListQuery.php โ”‚ โ”œโ”€โ”€ DTOs/ # Data Transfer Objects โ”‚ โ”‚ โ”œโ”€โ”€ CreatePostDTO.php โ”‚ โ”‚ โ””โ”€โ”€ UpdatePostDTO.php โ”‚ โ””โ”€โ”€ UseCases/ # Use cases โ”‚ โ”œโ”€โ”€ CreatePostUseCase.php โ”‚ โ””โ”€โ”€ PublishPostUseCase.php โ”œโ”€โ”€ Infrastructure/ # Warstwa infrastruktury โ”‚ โ”œโ”€โ”€ Repositories/ # Implementacje repozytoriรณw โ”‚ โ”‚ โ”œโ”€โ”€ EloquentPostRepository.php โ”‚ โ”‚ โ””โ”€โ”€ EloquentCategoryRepository.php โ”‚ โ”œโ”€โ”€ External/ # Zewnฤ™trzne serwisy โ”‚ โ”‚ โ””โ”€โ”€ EmailService.php โ”‚ โ””โ”€โ”€ Persistence/ # Modele Eloquent โ”‚ โ”œโ”€โ”€ PostModel.php โ”‚ โ””โ”€โ”€ CategoryModel.php โ”œโ”€โ”€ Presentation/ # Warstwa prezentacji โ”‚ โ”œโ”€โ”€ Http/ โ”‚ โ”‚ โ”œโ”€โ”€ Controllers/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Admin/ โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ PostController.php โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ Api/ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ PostController.php โ”‚ โ”‚ โ”œโ”€โ”€ Requests/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ CreatePostRequest.php โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ UpdatePostRequest.php โ”‚ โ”‚ โ”œโ”€โ”€ Resources/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ PostResource.php โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ PostCollection.php โ”‚ โ”‚ โ””โ”€โ”€ Middleware/ โ”‚ โ”‚ โ””โ”€โ”€ CheckBlogAccess.php โ”‚ โ””โ”€โ”€ Console/ โ”‚ โ””โ”€โ”€ Commands/ โ”‚ โ””โ”€โ”€ PublishScheduledPosts.php โ”œโ”€โ”€ Resources/ โ”‚ โ”œโ”€โ”€ views/ โ”‚ โ”œโ”€โ”€ lang/ โ”‚ โ””โ”€โ”€ assets/ โ”œโ”€โ”€ Routes/ โ”‚ โ”œโ”€โ”€ web.php โ”‚ โ””โ”€โ”€ api.php โ”œโ”€โ”€ Tests/ โ”‚ โ”œโ”€โ”€ Unit/ โ”‚ โ”‚ โ”œโ”€โ”€ Domain/ โ”‚ โ”‚ โ””โ”€โ”€ Application/ โ”‚ โ””โ”€โ”€ Feature/ โ”‚ โ””โ”€โ”€ Http/ โ””โ”€โ”€ Providers/ โ””โ”€โ”€ BlogServiceProvider.php

๐Ÿ“‹ Polecenia dla struktury DDD:

php artisan module:make-model Domain/Entities/Post Blog # Encja domenowa php artisan module:make-model Domain/ValueObjects/PostStatus Blog # Value Object php artisan module:make-model Infrastructure/Repositories/EloquentPostRepository Blog php artisan module:make-model Application/UseCases/CreatePostUseCase Blog # Use Case php artisan module:make-model Application/DTOs/CreatePostDTO Blog # DTO php artisan module:make-controller Presentation/Http/Controllers/Admin/PostController Blog php artisan module:make-model Domain/Services/PostService Blog # Serwis domenowy
๐Ÿ’ก Tip: Uลผyj php artisan list aby zobaczyฤ‡ wszystkie dostฤ™pne polecenia, a php artisan help <command> dla szczegรณล‚owej pomocy.