### 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
Save Saving... ``` -------------------------------- ### 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 --}} Save Changes Delete {{-- Alert --}} Your changes have been saved successfully! {{-- Card --}} {{-- Badge --}} Published Draft ``` -------------------------------- ### Authenticate as a user in tests Source: https://www.laracorekit.com/docs/advanced/testing Use these helpers to authenticate as a user, with a specific role, or to test unauthenticated access. The first example creates a user and authenticates them. The second creates an admin with the 'admin' role and authenticates. The third tests that unauthenticated access to the dashboard redirects to the login page. ```php // Authenticate as a user in tests $user = User::factory()->create(); $this->actingAs($user); // Authenticate with a specific role $admin = User::factory()->create(); $admin->assignRole('admin'); $this->actingAs($admin); // Test unauthenticated access $this->get(route('dashboard'))->assertRedirect('/login'); ``` -------------------------------- ### Feature test example Source: https://www.laracorekit.com/docs/advanced/testing A sample Feature test class demonstrating how to use factories and assertions to test blog post visibility and HTTP responses. ```php count(5)->published()->create(); Post::factory()->count(3)->draft()->create(); $response = $this->get(route('blog.index')); $response ->assertOk() ->assertViewHas('posts') ->assertViewHas('posts', fn ($posts) => $posts->count() === 5); } /** @test */ public function it_shows_a_published_post(): void { $post = Post::factory()->published()->create([ 'title' => 'Test Post Title', ]); $this->get(route('blog.show', $post->slug)) ->assertOk() ->assertSee('Test Post Title'); } /** @test */ public function it_returns_404_for_draft_post(): void { $post = Post::factory()->draft()->create(); $this->get(route('blog.show', $post->slug)) ->assertNotFound(); } } ``` -------------------------------- ### Full PostResource Implementation Source: https://www.laracorekit.com/docs/admin/resources A complete example of a Filament Resource class, including form schema, table columns, filters, actions, and page routing. ```php schema([ Forms\Components\Grid::make(2)->schema([ Forms\Components\TextInput::make('title') ->required() ->maxLength(255) ->live(onBlur: true) ->afterStateUpdated(fn ($state, $set) => $set('slug', \Str::slug($state)) ), Forms\Components\TextInput::make('slug') ->required() ->unique(ignoreRecord: true), ]), Forms\Components\Select::make('status') ->options(['draft' => 'Draft', 'published' => 'Published']) ->default('draft') ->required(), Forms\Components\Select::make('locale') ->options(['en' => 'English', 'hi' => 'Hindi', 'ar' => 'Arabic']) ->default('en') ->required(), Forms\Components\Textarea::make('excerpt') ->rows(2) ->maxLength(500), Forms\Components\RichEditor::make('content') ->columnSpanFull() ->required(), Forms\Components\SpatieMediaLibraryFileUpload::make('cover') ->collection('cover') ->image() ->imageResizeMode('cover'), Forms\Components\DateTimePicker::make('published_at'), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('title')->searchable()->sortable(), Tables\Columns\BadgeColumn::make('status') ->colors(['warning' => 'draft', 'success' => 'published']), Tables\Columns\TextColumn::make('locale')->label('Lang'), Tables\Columns\TextColumn::make('published_at')->since()->sortable(), ]) ->filters([ Tables\Filters\SelectFilter::make('status') ->options(['draft' => 'Draft', 'published' => 'Published']), Tables\Filters\SelectFilter::make('locale') ->options(['en' => 'English', 'hi' => 'Hindi', 'ar' => 'Arabic']), ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make(), ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), ]); } public static function getPages(): array { return [ 'index' => Pages\ListPosts::route('/'), 'create' => Pages\CreatePost::route('/create'), 'edit' => Pages\EditPost::route('/{record}/edit'), ]; } } ``` -------------------------------- ### Configure PostgreSQL database in .env Source: https://www.laracorekit.com/docs/installation Edit the .env file to use PostgreSQL as the database connection. Set the host, port, database name, username, and password to match your PostgreSQL setup. ```bash DB_CONNECTION=pgsql DB_HOST=127.0.0.1 DB_PORT=5432 DB_DATABASE=laracorekit DB_USERNAME=postgres DB_PASSWORD=your_password ``` -------------------------------- ### Set up Docker with Laravel Sail Source: https://www.laracorekit.com/docs/faq Set up Docker with Laravel Sail for local development. ```bash composer require laravel/sail --dev php artisan sail:install ./vendor/bin/sail up ``` -------------------------------- ### Extend Layout with Livewire Component Source: https://www.laracorekit.com/docs/frontend/layouts Example of using the layout method within a Livewire component to render content inside the core app layout. ```php class BlogList extends Component { public function render() { return view('blog::livewire.blog-list') ->layout('core::layouts.app', [ 'title' => 'Blog - ' . config('app.name'), ]); } } ``` -------------------------------- ### Update .env.example for repository Source: https://www.laracorekit.com/docs/deployment/demo-setup Update .env.example in the repository with these variables, keeping DEMO_MODE=false for contributors and documentation. ```env # Demo Mode (set to true on demo server only) DEMO_MODE=false DEMO_RESET_INTERVAL=30 DEMO_ADMIN_EMAIL=admin@laracorekit.com DEMO_ADMIN_PASSWORD=Admin@123 DEMO_USER_EMAIL=user@laracorekit.com DEMO_USER_PASSWORD=User@123 ``` -------------------------------- ### Create new repository for demo-module Source: https://www.laracorekit.com/docs/deployment/demo-setup Creates a new repository for the standalone package and clones it locally. ```bash # On GitHub, create: laracorekit/demo-module git clone https://github.com/laracorekit/demo-module.git cd demo-module ``` -------------------------------- ### Deployment Script and Execution Source: https://www.laracorekit.com/docs/deployment/production Deployment script for LaraCoreKit. Run it to pull latest code, install dependencies, build frontend, cache config, run migrations, and restart queue workers. Make it executable with chmod +x and run it. ```bash #!/bin/bash set -e # Navigate to app cd /var/www/laracorekit # Pull latest code git pull origin main # Install/update PHP dependencies composer install --no-dev --optimize-autoloader --no-interaction # Install/build frontend npm ci && npm run build # Cache everything php artisan config:cache php artisan route:cache php artisan view:cache php artisan event:cache # Run migrations php artisan migrate --force # Create storage symlink (if not exists) php artisan storage:link # Restart queue workers php artisan queue:restart echo " Deployment complete!" ``` ```bash chmod +x deploy.sh ./deploy.sh ``` -------------------------------- ### Enable Nginx Site and Restart Source: https://www.laracorekit.com/docs/installation Creates a symlink to enable the laracorekit Nginx site, tests the configuration, and restarts Nginx. ```bash sudo ln -s /etc/nginx/sites-available/laracorekit /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx ``` -------------------------------- ### Check environment versions (php -v, composer -V, node -v) Source: https://www.laracorekit.com/docs/quick-start Checks that PHP, Composer, and Node.js meet the minimum versions required by LaraCoreKit. Run these commands before installation to confirm your environment is ready. ```bash php -v # Should show 8.2+ composer -V # Should show 2.x node -v # Should show 18+ ``` -------------------------------- ### Publish demo config file Source: https://www.laracorekit.com/docs/deployment/demo-setup Publishes the demo configuration file to config/demo.php. Run this command first to make the demo settings available for customization. ```bash php artisan vendor:publish --tag=demo-config ``` -------------------------------- ### Troubleshoot Demo Banner Visibility Source: https://www.laracorekit.com/docs/deployment/demo-setup Clear configuration and view caches, then verify demo configuration settings using tinker. ```bash // Check config php artisan config:clear php artisan tinker >>> config('demo.enabled') >>> config('demo.banner.show_on_login') // Clear view cache php artisan view:clear ``` -------------------------------- ### Register and Start Supervisor Worker Source: https://www.laracorekit.com/docs/installation Commands to reread Supervisor configuration, update, and start the laracorekit-worker process group. ```bash sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl start laracorekit-worker:* ``` -------------------------------- ### Clone LaraCoreKit and Configure Production Dependencies Source: https://www.laracorekit.com/docs/installation Clones the LaraCoreKit repository to /var/www, installs production dependencies, generates the app key, and sets proper ownership and permissions for Laravel directories. ```bash cd /var/www sudo git clone https://github.com/ProgrammerNomad/LaraCoreKit.git cd LaraCoreKit # Install dependencies (production) composer install --no-dev --optimize-autoloader npm install --production npm run build # Setup environment cp .env.example .env php artisan key:generate # Set permissions sudo chown -R www-data:www-data /var/www/LaraCoreKit sudo chmod -R 755 /var/www/LaraCoreKit sudo chmod -R 775 /var/www/LaraCoreKit/storage sudo chmod -R 775 /var/www/LaraCoreKit/bootstrap/cache ``` -------------------------------- ### Add HasMedia and InteractsWithMedia to a model Source: https://www.laracorekit.com/docs/features/media Setup for a Laravel model to use Spatie MediaLibrary. Add the HasMedia interface and InteractsWithMedia trait, then define media collections and conversions in registerMediaCollections() and registerMediaConversions(). ```php use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; class Post extends Model implements HasMedia { use InteractsWithMedia; public function registerMediaCollections(): void { $this->addMediaCollection('cover') ->singleFile() // Only one cover per post ->acceptsMimeTypes(['image/jpeg', 'image/png', 'image/webp']); } public function registerMediaConversions(Media $media = null): void { $this->addMediaConversion('thumb') ->width(400) ->height(300) ->sharpen(10); $this->addMediaConversion('og') ->width(1200) ->height(630); } } ``` -------------------------------- ### Enable demo module in .env Source: https://www.laracorekit.com/docs/deployment/demo-setup Set the environment variable to true to activate the module functionality. ```text # .env: DEMO_MODULE_ENABLED=true ``` -------------------------------- ### Run migrations and seed database Source: https://www.laracorekit.com/docs/installation Run database migrations and seed the database with default data. This creates all tables, seeds default roles and permissions, creates sample blog posts, and creates demo users if configured. ```bash php artisan migrate --seed ``` -------------------------------- ### Run migrations and seeders (php artisan migrate --seed) Source: https://www.laracorekit.com/docs/quick-start Runs database migrations and seeders. The expected output shows the migration and seeding progress; this creates database tables, a demo admin user, sample blog posts, and default roles & permissions. ```bash php artisan migrate --seed ``` ```text Migration table created successfully. Migrating: 2024_01_01_000000_create_users_table Migrated: 2024_01_01_000000_create_users_table (45.32ms) ... Seeding: DatabaseSeeder Seeded: DatabaseSeeder (123.45ms) Database seeding completed successfully. ``` -------------------------------- ### Filament Form Validation Examples Source: https://www.laracorekit.com/docs/admin/forms-tables Validation examples for form fields: email with unique rule and price with numeric constraints. All form fields support Laravel validation rules. ```php TextInput::make('email') ->email() ->required() ->unique('users', 'email', ignoreRecord: true) ->maxLength(255), TextInput::make('price') ->numeric() ->minValue(0) ->maxValue(99999), ``` -------------------------------- ### Add Module as Dev Dependency Source: https://www.laracorekit.com/docs/deployment/demo-setup Install the module as a development dependency. ```bash composer require laracorekit/demo-module --dev ``` -------------------------------- ### Recommended app.php configuration Source: https://www.laracorekit.com/docs/configuration Recommended settings for application name, timezone, and locale in config/app.php. Uses environment variables with defaults. ```php 'name' => env('APP_NAME', 'LaraCoreKit'), 'timezone' => 'UTC', 'locale' => env('APP_LOCALE', 'en'), 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), ``` -------------------------------- ### Module loading pipeline Source: https://www.laracorekit.com/docs/core/modules-system Shows the loading pipeline for modules, from config/modules.php through ModuleServiceProvider::register() to each module's ServiceProvider::boot() methods. ```text config/modules.php │ ▼ App\Providers\ModuleServiceProvider::register() │ (iterates enabled modules) │ ▼ Each Module's ServiceProvider::boot() │ ├── loadViewsFrom() ├── loadMigrationsFrom() ├── loadRoutesFrom() └── Livewire::component(...) ``` -------------------------------- ### Create Production Database and Run Migrations Source: https://www.laracorekit.com/docs/installation Creates the production MySQL database 'laracorekit_prod' with a dedicated user, grants privileges, and runs Laravel migrations. ```bash # Create production database mysql -u root -p << EOF CREATE DATABASE laracorekit_prod CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'laracorekit_user'@'localhost' IDENTIFIED BY 'secure_password_here'; GRANT ALL PRIVILEGES ON laracorekit_prod.* TO 'laracorekit_user'@'localhost'; FLUSH PRIVILEGES; EOF # Run migrations php artisan migrate --force ``` -------------------------------- ### Working with Users - Query and Update Source: https://www.laracorekit.com/docs/features/users Shows how to retrieve all users, find a user by email, and update profile fields using the User model. ```php use Modules\User\Models\User; // Get all users $users = User::all(); // Find by email $user = User::where('email', 'john@laracorekit.com')->first(); // Update profile $user->update(['name' => 'John Doe', 'bio' => 'Laravel developer']); ``` -------------------------------- ### Production recommended cache and queue settings Source: https://www.laracorekit.com/docs/configuration Environment variables for production using Redis for cache, queue, and session. ```bash CACHE_DRIVER=redis QUEUE_CONNECTION=redis SESSION_DRIVER=redis ``` -------------------------------- ### GET /api/settings Source: https://www.laracorekit.com/docs/api/endpoints Retrieves public site settings. This endpoint does not require authentication. ```APIDOC ## GET /api/settings ### Description Retrieves public site settings. This endpoint does not require authentication. ### Method GET ### Endpoint /api/settings ### Authentication No authentication required. ### Response #### Success Response (200) - **settings** (object) - Public site settings. #### Response Example { "settings": { "site_name": "LaraCoreKit", "tagline": "A Laravel starter kit" } } ``` -------------------------------- ### GET /api/posts Source: https://www.laracorekit.com/docs/api/endpoints Lists published blog posts. This endpoint does not require authentication. ```APIDOC ## GET /api/posts ### Description Lists published blog posts. This endpoint does not require authentication. ### Method GET ### Endpoint /api/posts ### Authentication No authentication required. ### Parameters #### Query Parameters - **locale** (string) - Optional - Filter by language. Default: `en`. - **page** (integer) - Optional - Page number. Default: `1`. - **per_page** (integer) - Optional - Items per page (max 100). Default: `15`. ### Request Example GET /api/posts?locale=en&page=1&per_page=15 ### Response #### Success Response (200) - **data** (array) - List of posts. - **meta** (object) - Pagination metadata. - **links** (object) - Pagination links. #### Response Example { "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" } } ``` -------------------------------- ### Run Database Migrations Source: https://www.laracorekit.com/docs/installation Execute database migrations and seed the database. ```bash ./vendor/bin/sail artisan migrate --seed ``` -------------------------------- ### Configure demo environment variables Source: https://www.laracorekit.com/docs/deployment/demo-setup Configure demo mode and credentials in the .env file. Set DEMO_MODE to true and adjust the reset interval and admin/user credentials as needed. ```dotenv DEMO_MODE=true DEMO_RESET_INTERVAL=30 DEMO_ADMIN_EMAIL=admin@laracorekit.com DEMO_ADMIN_PASSWORD=Admin@123 DEMO_USER_EMAIL=user@laracorekit.com DEMO_USER_PASSWORD=User@123 ``` -------------------------------- ### Configure SQLite database (Option A) Source: https://www.laracorekit.com/docs/quick-start Configures the database connection for SQLite (Option A, recommended for local development). The first block shows the .env settings, and the second creates the SQLite database file. ```ini DB_CONNECTION=sqlite # DB_DATABASE=database/database.sqlite # Commented out for SQLite ``` ```bash touch database/database.sqlite ``` -------------------------------- ### Module-Specific Layout Source: https://www.laracorekit.com/docs/frontend/layouts Example of a module-specific layout file (modules/Blog/views/layouts/blog.blade.php) that extends the core app layout. ```blade @extends('core::layouts.app') @section('content')
{{ $slot }}
@endsection ``` -------------------------------- ### GET /api/posts/{slug} Source: https://www.laracorekit.com/docs/api/endpoints Retrieves a single published post by its slug. This endpoint does not require authentication. ```APIDOC ## GET /api/posts/{slug} ### Description Retrieves a single published post by its slug. This endpoint does not require authentication. ### Method GET ### Endpoint /api/posts/{slug} ### Authentication No authentication required. ### Parameters #### Path Parameters - **slug** (string) - Required - The slug of the post. ### Request Example GET /api/posts/first-post ### Response #### Success Response (200) - **data** (object) - The post object. #### Response Example { "data": { "id": 1, "title": "First Post", "slug": "first-post" } } ``` -------------------------------- ### Cache for Production Source: https://www.laracorekit.com/docs/configuration Commands to cache config, routes, views, and optimize for production. ```bash php artisan config:cache php artisan route:cache php artisan view:cache php artisan optimize ``` -------------------------------- ### GET /api/user Source: https://www.laracorekit.com/docs/api/endpoints Retrieves the authenticated user's profile information. This endpoint requires authentication. ```APIDOC ## GET /api/user ### Description Retrieves the authenticated user's profile information. This endpoint requires authentication. ### Method GET ### Endpoint /api/user ### Authentication Requires authentication. ### Response #### Success Response (200) - **id** (integer) - User ID. - **name** (string) - User's name. - **email** (string) - User's email. #### Response Example { "id": 1, "name": "John Doe", "email": "john@example.com" } ``` -------------------------------- ### Database Configuration in .env Source: https://www.laracorekit.com/docs/configuration Sets the connection parameters for the database. ```text DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laracorekit DB_USERNAME=root DB_PASSWORD= ``` -------------------------------- ### Display media in Blade template Source: https://www.laracorekit.com/docs/features/media Blade template example for rendering a media thumbnail with lazy loading. ```blade {{ $post->title }} ``` -------------------------------- ### Token Issuance Request and Response Source: https://www.laracorekit.com/docs/api/sanctum Example cURL request to obtain a token and the corresponding JSON response. ```bash curl -X POST https://www.laracorekit.com/api/tokens \ -H "Content-Type: application/json" \ -d '{"email":"user@laracorekit.com","password":"secret","device_name":"My App"}' ``` ```json { "token": "1|abc123def456...", "user": { "id": 1, "name": "John Doe", "email": "john@laracorekit.com" } } ``` -------------------------------- ### Manual demo reset and verification Source: https://www.laracorekit.com/docs/deployment/demo-setup Use this to manually reset the demo database on the server. It changes to the project directory, runs the reset command, and then verifies the reset by counting users and posts via tinker. ```bash cd /var/www/vhosts/laracorekit.com # Run manual reset php artisan demo:reset --force # Verify database was reset php artisan tinker >>> \App\Models\User::count() >>> \Modules\Blog\Models\Post::count() ``` -------------------------------- ### Troubleshoot Demo Reset Failures Source: https://www.laracorekit.com/docs/deployment/demo-setup Check Laravel logs, run the reset command with verbose output, and verify the database connection via tinker. ```bash tail -f storage/logs/laravel.log # Run manually with verbose output php artisan demo:reset --force -vvv # Check database connection php artisan tinker >>> DB::connection()->getPdo() ``` -------------------------------- ### Cache and Session Configuration in .env Source: https://www.laracorekit.com/docs/configuration Defines the drivers for caching, sessions, and queue connections. ```text CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_CONNECTION=sync ```