Basic Artisan Commands

Category:

Author:
AI
Cyberpunk robot

Tags:

				
					php artisan list
				
			

Displays a list of all available Artisan commands.

				
					php artisan help <command>
				
			

Provides details and available options for a specific command.

				
					php artisan tinker
				
			

Opens an interactive shell to interact with your application’s models and logic in real-time.

				
					php artisan serve
				
			

Starts the built-in web server for local development (default is port 8000).

				
					php artisan migrate
				
			

Runs all pending migrations to update your database schema.

				
					php artisan migrate:rollback
				
			

Rolls back the last database migration.

				
					php artisan migrate:reset
				
			

Rolls back all migrations.

				
					php artisan migrate:refresh
				
			

Rolls back all migrations and re-runs them.

				
					php artisan migrate:status
				
			

Displays the status of each migration (whether it has been run or not).

				
					php artisan make:model <ModelName>
				
			

Creates a new Eloquent model.

				
					php artisan make:controller <ControllerName>
				
			

Generates a new controller.

				
					php artisan make:migration <MigrationName>
				
			

Creates a new migration file in the database/migrations directory.

				
					php artisan make:seeder <SeederName>
				
			

Generates a seeder file for populating the database with test data.

				
					php artisan make:factory <FactoryName>
				
			

Creates a factory for generating test data.

				
					php artisan make:middleware <MiddlewareName>
				
			

Generates a new middleware.

				
					php artisan make:policy <PolicyName>
				
			

Creates a policy class for handling authorization logic.

				
					php artisan make:command <CommandName>
				
			

Creates a custom Artisan command.

				
					php artisan make:event <EventName>
				
			

Generates a new event class.

				
					php artisan make:listener <ListenerName>
				
			

Creates a listener for events.

				
					php artisan make:job <JobName>
				
			

Generates a new job for queue processing.

				
					php artisan make:notification <NotificationName>
				
			

Creates a notification class.

				
					php artisan make:mail <MailName>
				
			

Generates a class for sending emails.

				
					php artisan make:request <RequestName>
				
			

Creates a custom form request class for validating incoming HTTP requests.

				
					php artisan make:resource <ResourceName>
				
			

Generates a resource class for transforming data into JSON for APIs.

				
					php artisan make:rule <RuleName>
				
			

Creates a custom validation rule.

				
					php artisan make:test <TestName>
				
			

Creates a test class for unit or feature tests.

				
					php artisan make:observer <ObserverName>
				
			

Generates a new observer class to handle model events.

These commands cover the majority of common tasks developers need when working with Laravel. Whether managing migrations, caching, queues, or creating resources, Artisan provides an efficient and standardized way to handle your Laravel application.

Recent posts