Overview
LaraCMS includes custom Artisan commands to help with common administrative tasks. Commands are located inapp/Console/Commands/ and can be run from the command line.
Available Commands
AssignSuperAdmin
Assigns the Super Admin role to a user by email address. Location:app/Console/Commands/AssignSuperAdmin.php
Command Signature
Parameters
email(required) - The email address of the user to assign Super Admin role
Usage Examples
Command Implementation
What It Does
- Finds user by the provided email address
- Creates role if “Super Admin” role doesn’t exist
- Checks existing role to prevent duplicate assignments
- Assigns role using Spatie Laravel Permission package
- Provides feedback with success or error messages
Output Messages
Success:GenerateSitemap
Generates an XML sitemap for your LaraCMS site. Location:app/Console/Commands/GenerateSitemap.php
Command Signature
Parameters
None - uses configuration fromconfig/sitemap.php and config/app.php
Usage Examples
Command Implementation
What It Does
- Crawls your site starting from the app URL (defined in
config/app.php) - Filters out protected URLs:
/admin- Admin dashboard/login- Login page/register- Registration page/confirm-password- Password confirmation/verify-email- Email verification
- Generates XML sitemap with all public pages
- Writes to file at
public/sitemap.xml
Output
Success:https://yourdomain.com/sitemap.xml
Sitemap Configuration
Configure sitemap options inconfig/sitemap.php:
Scheduling Sitemap Generation
Automatically regenerate the sitemap daily by adding toapp/Console/Kernel.php:
Creating Custom Commands
Generate a New Command
app/Console/Commands/.
Command Template
Command Best Practices
1. Use Descriptive Signatures
Make command signatures clear and follow Laravel conventions:2. Provide Clear Descriptions
3. Handle Errors Gracefully
4. Provide User Feedback
Useinfo(), error(), warn(), and comment() methods:
5. Use Arguments and Options
6. Confirm Destructive Actions
Common Command Patterns
Database Operations
User Input
Table Output
Running Commands
Locally
In Production
Via Scheduler
Add toapp/Console/Kernel.php:
Testing Commands
Next Steps
- Learn about Livewire Components
- Explore Customization Options
- Review Configuration Settings