### Local Environment Setup Source: https://www.laracorekit.com/docs/contributing Commands to configure the environment, install dependencies, generate an application key, and run migrations. ```bash cp .env.example .env composer install npm install php artisan key:generate php artisan migrate --seed npm run dev ``` -------------------------------- ### Update Documentation for Optional Module Source: https://www.laracorekit.com/docs/deployment/demo-setup Example documentation content for installing and removing the optional demo module. ```markdown ## Demo Module (Optional) Install demo auto-reset functionality: composer require laracorekit/demo-module Remove when not needed: composer remove laracorekit/demo-module ``` -------------------------------- ### Install Laravel Telescope Source: https://www.laracorekit.com/docs/deployment/demo-setup Install Laravel Telescope for monitoring. Run these commands to add the package, install its assets, and run migrations. ```bash composer require laravel/telescope php artisan telescope:install php artisan migrate ``` -------------------------------- ### Resource File Path Example Source: https://www.laracorekit.com/docs/admin/resources An example of the file path for a PostResource within the Blog module. ```text modules/Blog/src/Filament/Resources/PostResource.php ``` -------------------------------- ### Install demo module with Composer Source: https://www.laracorekit.com/docs/deployment/demo-setup Install the demo module package via Composer. ```bash composer require programmernomad/laracorekit-demo-module ``` -------------------------------- ### Add Algolia to Front-end with instantsearch.js Source: https://www.laracorekit.com/docs/advanced/search Install the Algolia front-end packages and initialize instantsearch with your Algolia credentials. The JavaScript block sets up the search client and starts the search widget. ```bash npm install algoliasearch instantsearch.js ``` ```javascript import algoliasearch from 'algoliasearch/lite'; import instantsearch from 'instantsearch.js'; const searchClient = algoliasearch('YOUR_APP_ID', 'YOUR_SEARCH_KEY'); const search = instantsearch({ indexName: 'blog_posts', searchClient, }); search.start(); ``` -------------------------------- ### Query Parameters Example Source: https://www.laracorekit.com/docs/api/endpoints Example of a GET request with query parameters for list endpoints. ```http GET /api/posts?locale=en&status=published&page=1&per_page=12 ``` -------------------------------- ### BlogServiceProvider example Source: https://www.laracorekit.com/docs/core/modules-system Example service provider for a module. It loads migrations, views, Livewire components, and routes in the boot method. ```php namespace Modules\Blog; use Illuminate\Support\ServiceProvider; use Livewire\Livewire; class BlogServiceProvider extends ServiceProvider { public function register(): void { // Bind interfaces, share config, etc. } public function boot(): void { // Load migrations $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); // Load Blade views under 'blog::' namespace $this->loadViewsFrom(__DIR__ . '/../views', 'blog'); // Register Livewire components Livewire::component('blog.blog-list', \Modules\Blog\Http\Livewire\BlogList::class); Livewire::component('blog.blog-detail', \Modules\Blog\Http\Livewire\BlogDetail::class); // Load routes $this->loadRoutesFrom(__DIR__ . '/../routes/web.php'); } } ``` -------------------------------- ### Install Laravel Telescope to see SQL queries Source: https://www.laracorekit.com/docs/faq Install Laravel Telescope to see SQL queries. Requires running the migration and then visiting /telescope. ```bash composer require laravel/telescope --dev php artisan telescope:install php artisan migrate ``` -------------------------------- ### Install JavaScript Dependencies Source: https://www.laracorekit.com/docs/installation Install Node.js dependencies and build assets. ```bash ./vendor/bin/sail npm install ./vendor/bin/sail npm run build ``` -------------------------------- ### Route Registration Example Source: https://www.laracorekit.com/docs/api/endpoints Example of registering routes for the new API endpoint in modules/Blog/routes/api.php. ```php Route::prefix('api')->group(function () { Route::get('/posts', [PostApiController::class, 'index']); Route::get('/posts/{slug}', [PostApiController::class, 'show']); }); ``` -------------------------------- ### Start development server (php artisan serve) Source: https://www.laracorekit.com/docs/quick-start Starts the Laravel development server. The expected output shows the server URL and how to stop it. ```bash php artisan serve ``` ```text INFO Server running on [http://127.0.0.1:8000]. Press Ctrl+C to stop the server ``` -------------------------------- ### Setup Database Queue Table Source: https://www.laracorekit.com/docs/advanced/queues Create and migrate the jobs table when using the database driver. ```bash php artisan queue:table php artisan migrate ``` -------------------------------- ### Install via Packagist for Local Development Source: https://www.laracorekit.com/docs/deployment/demo-setup Use this command to install the demo module as a development dependency. ```bash composer require programmernomad/laracorekit-demo-module --dev ``` -------------------------------- ### PostApiController Example Source: https://www.laracorekit.com/docs/api/endpoints Example controller for a new API endpoint, showing index and show methods. ```php namespace Modules\Blog\Http\Controllers\Api; use Illuminate\Http\JsonResponse; use Illuminate\Routing\Controller; use Modules\Blog\Models\Post; class PostApiController extends Controller { public function index(): JsonResponse { $posts = Post::published() ->locale(request('locale', 'en')) ->latest() ->paginate(request('per_page', 15)); return response()->json($posts); } public function show(string $slug): JsonResponse { $post = Post::published()->where('slug', $slug)->firstOrFail(); return response()->json(['data' => $post]); } } ``` -------------------------------- ### Install Laravel Scout Source: https://www.laracorekit.com/docs/advanced/search Install Laravel Scout and publish its configuration. Run these commands in your project root. ```bash composer require laravel/scout php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider" ``` -------------------------------- ### Install Module in Project Source: https://www.laracorekit.com/docs/modules/publishing Commands to install the package via Composer and run migrations. ```bash composer require programmernomad/laracorekit-newsletter php artisan migrate ``` -------------------------------- ### Set up environment file and generate application key Source: https://www.laracorekit.com/docs/quick-start Copies the example environment file and generates a fresh application key. The expected output confirms the key was set successfully. ```bash cp .env.example .env php artisan key:generate ``` ```text Application key set successfully. ``` -------------------------------- ### Set up database queues Source: https://www.laracorekit.com/docs/faq Configure the queue connection to database in .env, then create the queue table, run migrations, and start the queue worker. For production, use Supervisor. ```env QUEUE_CONNECTION=database ``` ```bash php artisan queue:table php artisan migrate php artisan queue:work ``` -------------------------------- ### Install dependencies with composer install and npm install Source: https://www.laracorekit.com/docs/quick-start Installs PHP and JavaScript dependencies for LaraCoreKit. The expected output shows the package installation progress; this step typically takes 2-3 minutes. ```bash composer install npm install ``` ```text Installing dependencies from lock file Package operations: 127 installs, 0 updates, 0 removals - Installing doctrine/inflector (2.0.8) - Installing illuminate/contracts (v11.x-dev) ... ``` -------------------------------- ### Run Development Servers Source: https://www.laracorekit.com/docs/quick-start Start the Laravel server and the Vite development server for hot reloading. ```bash # Terminal 1: Laravel server php artisan serve # Terminal 2: Vite dev server (hot reload) npm run dev ``` -------------------------------- ### Customize config/demo.php Source: https://www.laracorekit.com/docs/deployment/demo-setup Example customizations for config/demo.php: set allowed hosts, block specific actions, and customize the banner colors. ```php // config/demo.php 'allowed_hosts' => [ 'www.laracorekit.com', // Your demo domain 'localhost', '127.0.0.1', ], 'blocked_actions' => [ 'user.delete', 'role.delete', 'backup.run', // Add your custom actions ], 'banner' => [ 'background_color' => 'blue-50', // Change colors 'border_color' => 'blue-500', 'text_color' => 'blue-900', ], ``` -------------------------------- ### Install Composer Dependencies Source: https://www.laracorekit.com/docs/installation Install project dependencies using a temporary Docker container. ```bash docker run --rm \ -u "$(id -u):$(id -g)" \ -v $(pwd):/var/www/html \ -w /var/www/html \ laravelsail/php82-composer:latest \ composer install --ignore-platform-reqs ``` -------------------------------- ### Laravel Sail Development Commands Source: https://www.laracorekit.com/docs/deployment/docker Commands for installing, starting, and interacting with the Laravel Sail development environment. ```bash # Install Sail php artisan sail:install # Start all services (MySQL, Redis, etc.) ./vendor/bin/sail up -d # Run artisan commands inside container ./vendor/bin/sail artisan migrate ./vendor/bin/sail artisan queue:work # Run composer inside container ./vendor/bin/sail composer require some/package # Run npm inside container ./vendor/bin/sail npm run dev ``` -------------------------------- ### Install and Run Let's Encrypt SSL Certificate Source: https://www.laracorekit.com/docs/installation Installs Certbot and the Nginx plugin, then obtains an SSL certificate for laracorekit.com and www.laracorekit.com. ```bash sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d laracorekit.com -d www.laracorekit.com ``` -------------------------------- ### PHP translation file example Source: https://www.laracorekit.com/docs/features/multilingual For organized namespaced strings. Shows an example of lang/hi/auth.php with 'failed' and 'throttle' translations. ```php // lang/hi/auth.php return [ 'failed' => 'प्रमाण-पत्र इनमें से किसी से मेल नहीं खाते।', 'throttle' => 'बहुत अधिक लॉगिन प्रयास।', ]; ``` -------------------------------- ### Troubleshoot Composer Install Source: https://www.laracorekit.com/docs/installation Commands to clear the Composer cache and perform an installation with verbose output for debugging. ```bash # Clear Composer cache composer clear-cache # Install with verbose output composer install -vvv ``` -------------------------------- ### Copy .env.example and generate application key Source: https://www.laracorekit.com/docs/installation Copy the example environment file to .env and generate a unique application key using Artisan. This is required for encryption and session security. ```bash cp .env.example .env ``` ```bash php artisan key:generate ``` -------------------------------- ### Environment Configuration for Production Source: https://www.laracorekit.com/docs/installation Example .env values for production with APP_ENV=production, APP_DEBUG=false, MySQL database credentials, Redis caching, and SMTP mail configuration. ```ini APP_ENV=production APP_DEBUG=false APP_URL=https://www.laracorekit.com DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_DATABASE=laracorekit_prod DB_USERNAME=laracorekit_user DB_PASSWORD=secure_password_here CACHE_DRIVER=redis SESSION_DRIVER=redis QUEUE_CONNECTION=redis MAIL_MAILER=smtp MAIL_HOST=smtp.laracorekit.com MAIL_PORT=587 MAIL_USERNAME=your_email MAIL_PASSWORD=your_password ``` -------------------------------- ### Using Livewire Components Source: https://www.laracorekit.com/docs/frontend/components Examples of invoking pre-built interactive Livewire components. ```blade {{-- Blog listing with search & pagination --}} @livewire('blog.blog-list') {{-- Newsletter subscribe form --}} @livewire('newsletter.subscribe') {{-- Locale switcher dropdown --}} @livewire('locale-switcher') ``` -------------------------------- ### Deploy with Railway CLI Source: https://www.laracorekit.com/docs/deployment/hosting Install the Railway CLI, log in, initialize the project, add MySQL and Redis services, and deploy. Set environment variables in the Railway dashboard. ```bash # Install Railway CLI npm install -g @railway/cli # Login railway login # Initialize project railway init # Add services railway add mysql railway add redis # Deploy railway up ``` -------------------------------- ### Install Demo Module via Composer Source: https://www.laracorekit.com/docs/deployment/demo-setup Install the demo module package into your Laravel project. ```bash composer require laracorekit/demo-module ``` -------------------------------- ### Module route registration example Source: https://www.laracorekit.com/docs/project-structure Example of how a module's service provider registers its routes using loadRoutesFrom. This is placed in the module's BlogServiceProvider.php file. ```php // modules/Blog/src/BlogServiceProvider.php public function boot() { $this->loadRoutesFrom(__DIR__.'/routes/web.php'); } ``` -------------------------------- ### Pagination Response Example Source: https://www.laracorekit.com/docs/api/endpoints Example of a paginated response from list endpoints, showing data, meta, and links. ```json { "data": [ { "id": 1, "title": "First Post", "slug": "first-post" } ], "meta": { "current_page": 1, "last_page": 5, "per_page": 15, "total": 72 }, "links": { "first": "https://www.laracorekit.com/api/posts?page=1", "next": "https://www.laracorekit.com/api/posts?page=2", "prev": null, "last": "https://www.laracorekit.com/api/posts?page=5" } } ``` -------------------------------- ### Verify Installation Source: https://www.laracorekit.com/docs/installation Commands to check the Laravel version, list installed modules, and run health checks. ```bash # Check Laravel version php artisan --version # Check installed modules php artisan module:list # Run health checks php artisan about ``` -------------------------------- ### Install PHP, Composer, Node.js, MySQL, and Nginx Source: https://www.laracorekit.com/docs/installation Commands to update system and install required software for the Laravel production server. Installs PHP 8.3 CLI/FPM with MySQL, PostgreSQL, XML, Mbstring, and other extensions, plus Composer, Node.js 18, MySQL server, and Nginx. ```bash # Update system sudo apt update && sudo apt upgrade -y # Install PHP 8.3 sudo add-apt-repository ppa:ondrej/php sudo apt install php8.3-fpm php8.3-cli php8.3-mysql php8.3-pgsql \ php8.3-xml php8.3-mbstring php8.3-curl php8.3-zip \ php8.3-gd php8.3-bcmath php8.3-intl # Install Composer curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer # Install Node.js 18 curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt install -y nodejs # Install MySQL sudo apt install mysql-server # Install Nginx sudo apt install nginx ``` -------------------------------- ### Deploy with Fly.io CLI Source: https://www.laracorekit.com/docs/deployment/hosting Install flyctl, log in, launch (creates fly.toml), and deploy. Fly.io uses Docker-based deployment with global edge distribution. ```bash # Install flyctl curl -L https://fly.io/install.sh | sh # Login fly auth login # Initialize (creates fly.toml) fly launch # Deploy fly deploy ``` -------------------------------- ### Install and Configure Algolia Driver Source: https://www.laracorekit.com/docs/advanced/search Install the Algolia PHP client and configure Scout to use Algolia. Set the SCOUT_DRIVER, ALGOLIA_APP_ID, and ALGOLIA_SECRET environment variables. ```bash composer require algolia/algoliasearch-client-php # Set Scout driver to algolia SCOUT_DRIVER=algolia ALGOLIA_APP_ID=your-app-id ALGOLIA_SECRET=your-secret-key ``` -------------------------------- ### Supervisor Configuration Source: https://www.laracorekit.com/docs/advanced/queues Example configuration for running workers in production using Supervisor. ```ini [program:laracorekit-worker] process_name=%(program_name)s_%(process_num)02d command=php /var/www/html/artisan queue:work redis --sleep=3 --tries=3 --max-time=3600 autostart=true autorestart=true user=www-data numprocs=2 redirect_stderr=true stdout_logfile=/var/log/laracorekit-worker.log stopwaitsecs=3600 ``` -------------------------------- ### Using Form Components Source: https://www.laracorekit.com/docs/frontend/components Example of a form using LaraCoreKit input, select, toggle, and button components with Livewire integration. ```blade
``` -------------------------------- ### Use Sail Alias Source: https://www.laracorekit.com/docs/installation Examples of using the sail alias after configuration. ```bash sail up -d sail artisan migrate sail npm run dev ``` -------------------------------- ### Let's Encrypt SSL with Certbot Source: https://www.laracorekit.com/docs/deployment/hosting Install Certbot, issue a certificate for laracorekit.com and www.laracorekit.com, and enable auto-renewal via a systemd timer. ```bash # Install Certbot sudo apt install certbot python3-certbot-nginx # Issue certificate sudo certbot --nginx -d laracorekit.com -d www.laracorekit.com # Auto-renewal (runs twice daily) sudo systemctl enable certbot.timer ``` -------------------------------- ### Component Lifecycle Hooks Source: https://www.laracorekit.com/docs/frontend/livewire Examples of common lifecycle hooks like mount and updated. ```php class MyComponent extends Component { public function mount(): void { // Runs once when component mounts $this->loadData(); } public function updated($property): void { // Runs after any property updates } public function updatedQuery(): void { // Runs specifically when $query updates $this->resetPage(); } } ``` -------------------------------- ### Dispatching Jobs in Livewire Source: https://www.laracorekit.com/docs/advanced/queues Example of dispatching jobs from within a Livewire component. ```php class RegisterForm extends Component { public function register(): void { $user = User::create($this->validated()); // Dispatch to queue - don't block the response SendWelcomeEmail::dispatch($user); SendVerificationEmail::dispatch($user); $this->redirect(route('home')); } } ``` -------------------------------- ### Install JavaScript dependencies with npm or yarn Source: https://www.laracorekit.com/docs/installation Install JavaScript dependencies using either npm or Yarn. Choose one based on your preference; both are supported. ```bash npm install ``` ```bash yarn install ``` -------------------------------- ### Use Module in Blade Source: https://www.laracorekit.com/docs/modules/publishing Example of how to include the Livewire component in a Blade template. ```blade @livewire('newsletter.subscribe') ``` -------------------------------- ### Retrieve media URLs and check existence Source: https://www.laracorekit.com/docs/features/media Demonstrates how to get the first media URL, a specific conversion URL, all media items, and check if media exists for a collection. ```php // Get first media URL $coverUrl = $post->getFirstMediaUrl('cover'); // Get thumbnail conversion $thumbUrl = $post->getFirstMediaUrl('cover', 'thumb'); // Get all media $allImages = $post->getMedia('images'); // Check if media exists if ($post->hasMedia('cover')) { // ... } ``` -------------------------------- ### Running Queue Workers Source: https://www.laracorekit.com/docs/advanced/queues Commands to start and manage queue workers. ```bash # Basic worker php artisan queue:work # Worker with specifics php artisan queue:work redis --queue=emails,default --sleep=3 --tries=3 # Process only one job then stop php artisan queue:work --once # Graceful shutdown after current job php artisan queue:restart ``` -------------------------------- ### Start Laravel Sail Source: https://www.laracorekit.com/docs/installation Launch the application services in detached mode. ```bash ./vendor/bin/sail up -d ``` -------------------------------- ### Run queue worker command Source: https://www.laracorekit.com/docs/configuration Run this artisan command to start a queue worker. ```bash php artisan queue:work ``` -------------------------------- ### Manual Server Deployment Commands Source: https://www.laracorekit.com/docs/deployment/demo-setup A sequence of commands to pull the latest code, install dependencies, run migrations, seed data, and build assets on the server. ```bash ssh username@www.laracorekit.com cd /var/www/vhosts/laracorekit.com # Pull latest code git pull origin main # Install dependencies composer install --no-dev --optimize-autoloader # Publish demo config php artisan vendor:publish --tag=demo-config # Run migrations php artisan migrate --force # Seed demo data php artisan db:seed --force # Clear and cache php artisan config:cache php artisan route:cache php artisan view:cache # Build assets npm ci npm run build # Initial demo reset php artisan demo:reset --force ``` -------------------------------- ### config/modules.php module configuration Source: https://www.laracorekit.com/docs/core/modules-system Example configuration for enabling a module. Setting 'enabled' => false completely disables the module, preventing routes and migrations from loading. ```php return [ 'modules' => [ 'Blog' => [ 'enabled' => true, 'namespace' => 'Modules\\Blog', 'provider' => 'Modules\\Blog\\BlogServiceProvider', ], // ... more modules ], ]; ``` -------------------------------- ### Error Response Example Source: https://www.laracorekit.com/docs/api/endpoints Example of a generic error response. ```json { "message": "Unauthenticated.", "errors": {} } ``` -------------------------------- ### Deploy with Laravel Cloud CLI Source: https://www.laracorekit.com/docs/deployment/hosting Install the Laravel Cloud CLI, log in, and deploy from the project root. Laravel Cloud handles zero-downtime deployments, auto-scaling, SSL, queue workers, and cron jobs. ```bash # Install CLI curl -fsSL https://cloud.laravel.com/installer.sh | sh # Login cloud login # Deploy from your project root cloud deploy ``` -------------------------------- ### Create README.md for package Source: https://www.laracorekit.com/docs/deployment/demo-setup Placeholder for creating a README.md file for the package. ```text ``` -------------------------------- ### Login and Token Retrieval Source: https://www.laracorekit.com/docs/api/authentication Example of sending user credentials to the API and storing the returned token in localStorage. ```javascript const response = await fetch('/api/tokens', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify({ email: 'user@laracorekit.com', password: 'secret', device_name: 'My Mobile App', }), }); const { token, user } = await response.json(); // Store token securely localStorage.setItem('token', token); ``` -------------------------------- ### Validation Error Response Example Source: https://www.laracorekit.com/docs/api/endpoints Example of a validation error response. ```json { "message": "The email field is required.", "errors": { "email": ["The email field is required."] } } ``` -------------------------------- ### Adding a new language - JSON file Source: https://www.laracorekit.com/docs/features/multilingual Step 1: Create lang/{locale}.json with translations. Example for French. ```json // lang/fr.json { "Welcome": "Bienvenue", "Log in": "Se connecter" } ``` -------------------------------- ### Install PHP dependencies with composer install Source: https://www.laracorekit.com/docs/installation Install all PHP dependencies required by LaraCoreKit using Composer. If you encounter memory issues, use the COMPOSER_MEMORY_LIMIT=-1 variant to avoid memory exhaustion. ```bash composer install ``` ```bash COMPOSER_MEMORY_LIMIT=-1 composer install ``` -------------------------------- ### Roles - Assign, Check, and Get Roles Source: https://www.laracorekit.com/docs/features/users Demonstrates role management using Spatie Laravel Permission: assigning a role, checking for a role, and retrieving all roles. ```php // Assign a role $user->assignRole('editor'); // Check role $user->hasRole('admin'); // Get all roles $user->roles; ``` -------------------------------- ### Using Blade Components (x-tags) Source: https://www.laracorekit.com/docs/frontend/components Examples of standard Blade components including buttons, alerts, cards, and badges. ```blade {{-- Button --}}