id int64 1 5.19k | page_title stringclasses 93
values | section stringlengths 3 53 | description stringlengths 0 2.15k | code stringlengths 16 3.06k | category stringclasses 94
values | version stringclasses 1
value |
|---|---|---|---|---|---|---|
1 | Upgrade Guide | Updating the Laravel Installer | If you are using the Laravel installer CLI tool to create new Laravel applications, you should update your installer installation to be compatible with Laravel 12.x and the new Laravel starter kits. If you installed the Laravel installer via composer global require, you may update the installer using composer global up... | 1composer global update laravel/installer
composer global update laravel/installer | upgrade | 12 |
2 | Upgrade Guide | Updating the Laravel Installer | If you originally installed PHP and Laravel via php.new, you may simply re-run the php.new installation commands for your operating system to install the latest version of PHP and the Laravel installer: | 1/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.4)"
/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.4)" | upgrade | 12 |
3 | Upgrade Guide | Updating the Laravel Installer | 1# Run as administrator...2Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4'))
# Run as administrator...
Set-Exec... | upgrade | 12 | |
4 | Upgrade Guide | Updating the Laravel Installer | 1/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)"
/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)" | upgrade | 12 | |
5 | Upgrade Guide | Concurrency | Likelihood Of Impact: Low When invoking the Concurrency::run method with an associative array, the results of the concurrent operations are now returned with their associated keys: | 1$result = Concurrency::run([2 'task-1' => fn () => 1 + 1,3 'task-2' => fn () => 2 + 2,4]);5 6// ['task-1' => 2, 'task-2' => 4]
$result = Concurrency::run([
'task-1' => fn () => 1 + 1,
'task-2' => fn () => 2 + 2,
]);
// ['task-1' => 2, 'task-2' => 4] | upgrade | 12 |
6 | Upgrade Guide | Container | Likelihood Of Impact: Low The dependency injection container now respects the default value of class properties when resolving a class instance. If you were previously relying on the container to resolve a class instance without the default value, you may need to adjust your application to account for this new behavior... | 1class Example 2{ 3 public function __construct(public ?Carbon $date = null) {} 4} 5 6$example = resolve(Example::class); 7 8// <= 11.x 9$example->date instanceof Carbon;10 11// >= 12.x12$example->date === null;
class Example
{
public function __construct(public ?Carbon $date = null) {}
}
$example = resolve(E... | upgrade | 12 |
7 | Upgrade Guide | Database | Likelihood Of Impact: Low The Schema::getTables(), Schema::getViews(), and Schema::getTypes() methods now include the results from all schemas by default. You may pass the schema argument to retrieve the result for the given schema only: | 1// All tables on all schemas...2$tables = Schema::getTables();3 4// All tables on the 'main' schema...5$tables = Schema::getTables(schema: 'main');6 7// All tables on the 'main' and 'blog' schemas...8$tables = Schema::getTables(schema: ['main', 'blog']);
// All tables on all schemas...
$tables = Schema::getTables();
... | upgrade | 12 |
8 | Upgrade Guide | Database | The Schema::getTableListing() method now returns schema-qualified table names by default. You may pass the schemaQualified argument to change the behavior as desired: | 1$tables = Schema::getTableListing();2// ['main.migrations', 'main.users', 'blog.posts']3 4$tables = Schema::getTableListing(schema: 'main');5// ['main.migrations', 'main.users']6 7$tables = Schema::getTableListing(schema: 'main', schemaQualified: false);8// ['migrations', 'users']
$tables = Schema::getTableListing();
... | upgrade | 12 |
9 | Upgrade Guide | Eloquent | Likelihood Of Impact: Medium The HasUuids trait now returns UUIDs that are compatible with version 7 of the UUID spec (ordered UUIDs). If you would like to continue using ordered UUIDv4 strings for your model's IDs, you should now use the HasVersion4Uuids trait: | 1use Illuminate\Database\Eloquent\Concerns\HasUuids; 2use Illuminate\Database\Eloquent\Concerns\HasVersion4Uuids as HasUuids;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Concerns\HasVersion4Uuids as HasUuids; | upgrade | 12 |
10 | Upgrade Guide | Requests | Likelihood Of Impact: Low The $request->mergeIfMissing() method now allows merging nested array data using "dot" notation. If you were previously relying on this method to create a top-level array key containing the "dot" notation version of the key, you may need to adjust your application to account for this new behav... | 1$request->mergeIfMissing([2 'user.last_name' => 'Otwell',3]);
$request->mergeIfMissing([
'user.last_name' => 'Otwell',
]); | upgrade | 12 |
11 | Upgrade Guide | Validation | Likelihood Of Impact: Low The image validation rule no longer allows SVG images by default. If you would like to allow SVGs when using the image rule, you must explicitly allow them: | 1use Illuminate\Validation\Rules\File;2 3'photo' => 'required|image:allow_svg'4 5// Or...6'photo' => ['required', File::image(allowSvg: true)],
use Illuminate\Validation\Rules\File;
'photo' => 'required|image:allow_svg'
// Or...
'photo' => ['required', File::image(allowSvg: true)], | upgrade | 12 |
12 | Contribution Guide | PHPDoc | Below is an example of a valid Laravel documentation block. Note that the @param attribute is followed by two spaces, the argument type, two more spaces, and finally the variable name: | 1/** 2 * Register a binding with the container. 3 * 4 * @param string|array $abstract 5 * @param \Closure|string|null $concrete 6 * @param bool $shared 7 * @return void 8 * 9 * @throws \Exception10 */11public function bind($abstract, $concrete = null, $shared = false)12{13 // ...14}
/**
* Register a binding w... | contributions | 12 |
13 | Contribution Guide | PHPDoc | When the @param or @return attributes are redundant due to the use of native types, they can be removed: | 1/**2 * Execute the job.3 */4public function handle(AudioProcessor $processor): void5{6 //7}
/**
* Execute the job.
*/
public function handle(AudioProcessor $processor): void
{
//
} | contributions | 12 |
14 | Contribution Guide | PHPDoc | However, when the native type is generic, please specify the generic type through the use of the @param or @return attributes: | 1/** 2 * Get the attachments for the message. 3 * 4 * @return array<int, \Illuminate\Mail\Mailables\Attachment> 5 */ 6public function attachments(): array 7{ 8 return [ 9 Attachment::fromStorage('/path/to/file'),10 ];11}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\... | contributions | 12 |
15 | Installation | Installing PHP and the Laravel Installer | Before creating your first Laravel application, make sure that your local machine has PHP, Composer, and the Laravel installer installed. In addition, you should install either Node and NPM or Bun so that you can compile your application's frontend assets. If you don't have PHP and Composer installed on your local mach... | 1/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.4)"
/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.4)" | installation | 12 |
16 | Installation | Installing PHP and the Laravel Installer | 1# Run as administrator...2Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4'))
# Run as administrator...
Set-Exec... | installation | 12 | |
17 | Installation | Installing PHP and the Laravel Installer | 1/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)"
/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)" | installation | 12 | |
18 | Installation | Installing PHP and the Laravel Installer | After running one of the commands above, you should restart your terminal session. To update PHP, Composer, and the Laravel installer after installing them via php.new, you can re-run the command in your terminal. If you already have PHP and Composer installed, you may install the Laravel installer via Composer: | 1composer global require laravel/installer
composer global require laravel/installer | installation | 12 |
19 | Installation | Creating an Application | After you have installed PHP, Composer, and the Laravel installer, you're ready to create a new Laravel application. The Laravel installer will prompt you to select your preferred testing framework, database, and starter kit: | 1laravel new example-app
laravel new example-app | installation | 12 |
20 | Installation | Creating an Application | Once the application has been created, you can start Laravel's local development server, queue worker, and Vite development server using the dev Composer script: | 1cd example-app2npm install && npm run build3composer run dev
cd example-app
npm install && npm run build
composer run dev | installation | 12 |
21 | Installation | Databases and Migrations | Now that you have created your Laravel application, you probably want to store some data in a database. By default, your application's .env configuration file specifies that Laravel will be interacting with an SQLite database. During the creation of the application, Laravel created a database/database.sqlite file for y... | 1DB_CONNECTION=mysql2DB_HOST=127.0.0.13DB_PORT=33064DB_DATABASE=laravel5DB_USERNAME=root6DB_PASSWORD=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD= | installation | 12 |
22 | Installation | Databases and Migrations | If you choose to use a database other than SQLite, you will need to create the database and run your application's database migrations: | 1php artisan migrate
php artisan migrate | installation | 12 |
23 | Installation | Herd on macOS | If you develop on macOS, you can download the Herd installer from the Herd website. The installer automatically downloads the latest version of PHP and configures your Mac to always run Nginx in the background. Herd for macOS uses dnsmasq to support "parked" directories. Any Laravel application in a parked directory wi... | 1cd ~/Herd2laravel new my-app3cd my-app4herd open
cd ~/Herd
laravel new my-app
cd my-app
herd open | installation | 12 |
24 | Installation | Herd on Windows | You can download the Windows installer for Herd on the Herd website. After the installation finishes, you can start Herd to complete the onboarding process and access the Herd UI for the first time. The Herd UI is accessible by left-clicking on Herd's system tray icon. A right-click opens the quick menu with access to ... | 1cd ~\Herd2laravel new my-app3cd my-app4herd open
cd ~\Herd
laravel new my-app
cd my-app
herd open | installation | 12 |
25 | Installation | Installing Laravel Boost | Boost can be installed in Laravel 10, 11, and 12 applications running PHP 8.1 or higher. To get started, install Boost as a development dependency: | 1composer require laravel/boost --dev
composer require laravel/boost --dev | installation | 12 |
26 | Installation | Installing Laravel Boost | Once installed, run the interactive installer: | 1php artisan boost:install
php artisan boost:install | installation | 12 |
27 | Configuration | Introduction | All of the configuration files for the Laravel framework are stored in the config directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you. These configuration files allow you to configure things like your database connection information, your mail ... | 1php artisan about
php artisan about | configuration | 12 |
28 | Configuration | Introduction | If you're only interested in a particular section of the application overview output, you may filter for that section using the --only option: | 1php artisan about --only=environment
php artisan about --only=environment | configuration | 12 |
29 | Configuration | Introduction | Or, to explore a specific configuration file's values in detail, you may use the config:show Artisan command: | 1php artisan config:show database
php artisan config:show database | configuration | 12 |
30 | Configuration | Environment Variable Types | All variables in your .env files are typically parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the env() function: If you need to define an environment variable with a value that contains spaces, you may do so by enclosing the value in double quotes: | 1APP_NAME="My Application"
APP_NAME="My Application" | configuration | 12 |
31 | Configuration | Retrieving Environment Configuration | All of the variables listed in the .env file will be loaded into the $_ENV PHP super-global when your application receives a request. However, you may use the env function to retrieve values from these variables in your configuration files. In fact, if you review the Laravel configuration files, you will notice many of... | 1'debug' => (bool) env('APP_DEBUG', false),
'debug' => (bool) env('APP_DEBUG', false), | configuration | 12 |
32 | Configuration | Determining the Current Environment | The current application environment is determined via the APP_ENV variable from your .env file. You may access this value via the environment method on the App facade: | 1use Illuminate\Support\Facades\App;2 3$environment = App::environment();
use Illuminate\Support\Facades\App;
$environment = App::environment(); | configuration | 12 |
33 | Configuration | Determining the Current Environment | You may also pass arguments to the environment method to determine if the environment matches a given value. The method will return true if the environment matches any of the given values: | 1if (App::environment('local')) {2 // The environment is local3}4 5if (App::environment(['local', 'staging'])) {6 // The environment is either local OR staging...7}
if (App::environment('local')) {
// The environment is local
}
if (App::environment(['local', 'staging'])) {
// The environment is either lo... | configuration | 12 |
34 | Configuration | Encrypting Environment Files | Unencrypted environment files should never be stored in source control. However, Laravel allows you to encrypt your environment files so that they may safely be added to source control with the rest of your application. To encrypt an environment file, you may use the env:encrypt command: | 1php artisan env:encrypt
php artisan env:encrypt | configuration | 12 |
35 | Configuration | Encrypting Environment Files | Running the env:encrypt command will encrypt your .env file and place the encrypted contents in an .env.encrypted file. The decryption key is presented in the output of the command and should be stored in a secure password manager. If you would like to provide your own encryption key you may use the --key option when i... | 1php artisan env:encrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF
php artisan env:encrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF | configuration | 12 |
36 | Configuration | Encrypting Environment Files | The length of the key provided should match the key length required by the encryption cipher being used. By default, Laravel will use the AES-256-CBC cipher which requires a 32 character key. You are free to use any cipher supported by Laravel's encrypter by passing the --cipher option when invoking the command. If you... | 1php artisan env:encrypt --env=staging
php artisan env:encrypt --env=staging | configuration | 12 |
37 | Configuration | Encrypting Environment Files | To decrypt an environment file, you may use the env:decrypt command. This command requires a decryption key, which Laravel will retrieve from the LARAVEL_ENV_ENCRYPTION_KEY environment variable: | 1php artisan env:decrypt
php artisan env:decrypt | configuration | 12 |
38 | Configuration | Encrypting Environment Files | Or, the key may be provided directly to the command via the --key option: | 1php artisan env:decrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF
php artisan env:decrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF | configuration | 12 |
39 | Configuration | Encrypting Environment Files | When the env:decrypt command is invoked, Laravel will decrypt the contents of the .env.encrypted file and place the decrypted contents in the .env file. The --cipher option may be provided to the env:decrypt command in order to use a custom encryption cipher: | 1php artisan env:decrypt --key=qUWuNRdfuImXcKxZ --cipher=AES-128-CBC
php artisan env:decrypt --key=qUWuNRdfuImXcKxZ --cipher=AES-128-CBC | configuration | 12 |
40 | Configuration | Encrypting Environment Files | If your application has multiple environment files, such as .env and .env.staging, you may specify the environment file that should be decrypted by providing the environment name via the --env option: | 1php artisan env:decrypt --env=staging
php artisan env:decrypt --env=staging | configuration | 12 |
41 | Configuration | Encrypting Environment Files | In order to overwrite an existing environment file, you may provide the --force option to the env:decrypt command: | 1php artisan env:decrypt --force
php artisan env:decrypt --force | configuration | 12 |
42 | Configuration | Accessing Configuration Values | You may easily access your configuration values using the Config facade or global config function from anywhere in your application. The configuration values may be accessed using "dot" syntax, which includes the name of the file and option you wish to access. A default value may also be specified and will be returned ... | 1use Illuminate\Support\Facades\Config;2 3$value = Config::get('app.timezone');4 5$value = config('app.timezone');6 7// Retrieve a default value if the configuration value does not exist...8$value = config('app.timezone', 'Asia/Seoul');
use Illuminate\Support\Facades\Config;
$value = Config::get('app.timezone');
$val... | configuration | 12 |
43 | Configuration | Accessing Configuration Values | To set configuration values at runtime, you may invoke the Config facade's set method or pass an array to the config function: | 1Config::set('app.timezone', 'America/Chicago');2 3config(['app.timezone' => 'America/Chicago']);
Config::set('app.timezone', 'America/Chicago');
config(['app.timezone' => 'America/Chicago']); | configuration | 12 |
44 | Configuration | Accessing Configuration Values | To assist with static analysis, the Config facade also provides typed configuration retrieval methods. If the retrieved configuration value does not match the expected type, an exception will be thrown: | 1Config::string('config-key');2Config::integer('config-key');3Config::float('config-key');4Config::boolean('config-key');5Config::array('config-key');6Config::collection('config-key');
Config::string('config-key');
Config::integer('config-key');
Config::float('config-key');
Config::boolean('config-key');
Config::array(... | configuration | 12 |
45 | Configuration | Configuration Caching | To give your application a speed boost, you should cache all of your configuration files into a single file using the config:cache Artisan command. This will combine all of the configuration options for your application into a single file which can be quickly loaded by the framework. You should typically run the php ar... | 1php artisan config:clear
php artisan config:clear | configuration | 12 |
46 | Configuration | Configuration Publishing | Most of Laravel's configuration files are already published in your application's config directory; however, certain configuration files like cors.php and view.php are not published by default, as most applications will never need to modify them. However, you may use the config:publish Artisan command to publish any co... | 1php artisan config:publish2 3php artisan config:publish --all
php artisan config:publish
php artisan config:publish --all | configuration | 12 |
47 | Configuration | Maintenance Mode | When your application is in maintenance mode, a custom view will be displayed for all requests into your application. This makes it easy to "disable" your application while it is updating or when you are performing maintenance. A maintenance mode check is included in the default middleware stack for your application. I... | 1php artisan down
php artisan down | configuration | 12 |
48 | Configuration | Maintenance Mode | If you would like the Refresh HTTP header to be sent with all maintenance mode responses, you may provide the refresh option when invoking the down command. The Refresh header will instruct the browser to automatically refresh the page after the specified number of seconds: | 1php artisan down --refresh=15
php artisan down --refresh=15 | configuration | 12 |
49 | Configuration | Maintenance Mode | You may also provide a retry option to the down command, which will be set as the Retry-After HTTP header's value, although browsers generally ignore this header: | 1php artisan down --retry=60
php artisan down --retry=60 | configuration | 12 |
50 | Configuration | Maintenance Mode | To allow maintenance mode to be bypassed using a secret token, you may use the secret option to specify a maintenance mode bypass token: | 1php artisan down --secret="1630542a-246b-4b66-afa1-dd72a4c43515"
php artisan down --secret="1630542a-246b-4b66-afa1-dd72a4c43515" | configuration | 12 |
51 | Configuration | Maintenance Mode | After placing the application in maintenance mode, you may navigate to the application URL matching this token and Laravel will issue a maintenance mode bypass cookie to your browser: | 1https://example.com/1630542a-246b-4b66-afa1-dd72a4c43515
https://example.com/1630542a-246b-4b66-afa1-dd72a4c43515 | configuration | 12 |
52 | Configuration | Maintenance Mode | If you would like Laravel to generate the secret token for you, you may use the with-secret option. The secret will be displayed to you once the application is in maintenance mode: | 1php artisan down --with-secret
php artisan down --with-secret | configuration | 12 |
53 | Configuration | Maintenance Mode | When accessing this hidden route, you will then be redirected to the / route of the application. Once the cookie has been issued to your browser, you will be able to browse the application normally as if it was not in maintenance mode. Your maintenance mode secret should typically consist of alpha-numeric characters an... | 1APP_MAINTENANCE_DRIVER=cache2APP_MAINTENANCE_STORE=database
APP_MAINTENANCE_DRIVER=cache
APP_MAINTENANCE_STORE=database | configuration | 12 |
54 | Configuration | Maintenance Mode | If you utilize the php artisan down command during deployment, your users may still occasionally encounter errors if they access the application while your Composer dependencies or other infrastructure components are updating. This occurs because a significant part of the Laravel framework must boot in order to determi... | 1php artisan down --render="errors::503"
php artisan down --render="errors::503" | configuration | 12 |
55 | Configuration | Maintenance Mode | While in maintenance mode, Laravel will display the maintenance mode view for all application URLs the user attempts to access. If you wish, you may instruct Laravel to redirect all requests to a specific URL. This may be accomplished using the redirect option. For example, you may wish to redirect all requests to the ... | 1php artisan down --redirect=/
php artisan down --redirect=/ | configuration | 12 |
56 | Configuration | Maintenance Mode | To disable maintenance mode, use the up command: | 1php artisan up
php artisan up | configuration | 12 |
57 | Frontend | PHP and Blade | In the past, most PHP applications rendered HTML to the browser using simple HTML templates interspersed with PHP echo statements which render data that was retrieved from a database during the request: | 1<div>2 <?php foreach ($users as $user): ?>3 Hello, <?php echo $user->name; ?> <br />4 <?php endforeach; ?>5</div>
<div>
<?php foreach ($users as $user): ?>
Hello, <?php echo $user->name; ?> <br />
<?php endforeach; ?>
</div> | frontend | 12 |
58 | Frontend | PHP and Blade | In Laravel, this approach to rendering HTML can still be achieved using views and Blade. Blade is an extremely light-weight templating language that provides convenient, short syntax for displaying data, iterating over data, and more: | 1<div>2 @foreach ($users as $user)3 Hello, {{ $user->name }} <br />4 @endforeach5</div>
<div>
@foreach ($users as $user)
Hello, {{ $user->name }} <br />
@endforeach
</div> | frontend | 12 |
59 | Frontend | Livewire | Laravel Livewire is a framework for building Laravel powered frontends that feel dynamic, modern, and alive just like frontends built with modern JavaScript frameworks like Vue and React. When using Livewire, you will create Livewire "components" that render a discrete portion of your UI and expose methods and data tha... | 1<?php 2 3namespace App\Http\Livewire; 4 5use Livewire\Component; 6 7class Counter extends Component 8{ 9 public $count = 0;10 11 public function increment()12 {13 $this->count++;14 }15 16 public function render()17 {18 return view('livewire.counter');19 }20}
<?php
namespace App\H... | frontend | 12 |
60 | Frontend | Livewire | And, the corresponding template for the counter would be written like so: | 1<div>2 <button wire:click="increment">+</button>3 <h1>{{ $count }}</h1>4</div>
<div>
<button wire:click="increment">+</button>
<h1>{{ $count }}</h1>
</div> | frontend | 12 |
61 | Frontend | Inertia | Thankfully, Laravel offers the best of both worlds. Inertia bridges the gap between your Laravel application and your modern React or Vue frontend, allowing you to build full-fledged, modern frontends using React or Vue while leveraging Laravel routes and controllers for routing, data hydration, and authentication — al... | 1<?php 2 3namespace App\Http\Controllers; 4 5use App\Models\User; 6use Inertia\Inertia; 7use Inertia\Response; 8 9class UserController extends Controller10{11 /**12 * Show the profile for a given user.13 */14 public function show(string $id): Response15 {16 return Inertia::render('users/show'... | frontend | 12 |
62 | Frontend | Inertia | An Inertia page corresponds to a React or Vue component, typically stored within the resources/js/pages directory of your application. The data given to the page via the Inertia::render method will be used to hydrate the "props" of the page component: | 1import Layout from '@/layouts/authenticated'; 2import { Head } from '@inertiajs/react'; 3 4export default function Show({ user }) { 5 return ( 6 <Layout> 7 <Head title="Welcome" /> 8 <h1>Welcome</h1> 9 <p>Hello {user.name}, welcome to Inertia.</p>10 </Layout>11 )12... | frontend | 12 |
63 | Starter Kits | Creating an Application Using a Starter Kit | To create a new Laravel application using one of our starter kits, you should first install PHP and the Laravel CLI tool. If you already have PHP and Composer installed, you may install the Laravel installer CLI tool via Composer: | 1composer global require laravel/installer
composer global require laravel/installer | starter-kits | 12 |
64 | Starter Kits | Creating an Application Using a Starter Kit | Then, create a new Laravel application using the Laravel installer CLI. The Laravel installer will prompt you to select your preferred starter kit: | 1laravel new my-app
laravel new my-app | starter-kits | 12 |
65 | Starter Kits | Creating an Application Using a Starter Kit | After creating your Laravel application, you only need to install its frontend dependencies via NPM and start the Laravel development server: | 1cd my-app2npm install && npm run build3composer run dev
cd my-app
npm install && npm run build
composer run dev | starter-kits | 12 |
66 | Starter Kits | React | Our React starter kit is built with Inertia 2, React 19, Tailwind 4, and shadcn/ui. As with all of our starter kits, all of the backend and frontend code exists within your application to allow for full customization. The majority of the frontend code is located in the resources/js directory. You are free to modify any... | 1resources/js/2├── components/ # Reusable React components3├── hooks/ # React hooks4├── layouts/ # Application layouts5├── lib/ # Utility functions and configuration6├── pages/ # Page components7└── types/ # TypeScript definitions
resources/js/
├── components/ # Reusable Re... | starter-kits | 12 |
67 | Starter Kits | React | To publish additional shadcn components, first find the component you want to publish. Then, publish the component using npx: | 1npx shadcn@latest add switch
npx shadcn@latest add switch | starter-kits | 12 |
68 | Starter Kits | React | In this example, the command will publish the Switch component to resources/js/components/ui/switch.tsx. Once the component has been published, you can use it in any of your pages: | 1import { Switch } from "@/components/ui/switch" 2 3const MyPage = () => { 4 return ( 5 <div> 6 <Switch /> 7 </div> 8 ); 9};10 11export default MyPage;
import { Switch } from "@/components/ui/switch"
const MyPage = () => {
return (
<div>
<Switch />
</div>
);
};
export default MyPage; | starter-kits | 12 |
69 | Starter Kits | React | The React starter kit includes two different primary layouts for you to choose from: a "sidebar" layout and a "header" layout. The sidebar layout is the default, but you can switch to the header layout by modifying the layout that is imported at the top of your application's resources/js/layouts/app-layout.tsx file: | 1import AppLayoutTemplate from '@/layouts/app/app-sidebar-layout'; 2import AppLayoutTemplate from '@/layouts/app/app-header-layout';
import AppLayoutTemplate from '@/layouts/app/app-sidebar-layout';
import AppLayoutTemplate from '@/layouts/app/app-header-layout'; | starter-kits | 12 |
70 | Starter Kits | React | The sidebar layout includes three different variants: the default sidebar variant, the "inset" variant, and the "floating" variant. You may choose the variant you like best by modifying the resources/js/components/app-sidebar.tsx component: | 1<Sidebar collapsible="icon" variant="sidebar"> 2<Sidebar collapsible="icon" variant="inset">
<Sidebar collapsible="icon" variant="sidebar">
<Sidebar collapsible="icon" variant="inset"> | starter-kits | 12 |
71 | Starter Kits | React | The authentication pages included with the React starter kit, such as the login page and registration page, also offer three different layout variants: "simple", "card", and "split". To change your authentication layout, modify the layout that is imported at the top of your application's resources/js/layouts/auth-layou... | 1import AuthLayoutTemplate from '@/layouts/auth/auth-simple-layout'; 2import AuthLayoutTemplate from '@/layouts/auth/auth-split-layout';
import AuthLayoutTemplate from '@/layouts/auth/auth-simple-layout';
import AuthLayoutTemplate from '@/layouts/auth/auth-split-layout'; | starter-kits | 12 |
72 | Starter Kits | Vue | Our Vue starter kit is built with Inertia 2, Vue 3 Composition API, Tailwind, and shadcn-vue. As with all of our starter kits, all of the backend and frontend code exists within your application to allow for full customization. The majority of the frontend code is located in the resources/js directory. You are free to ... | 1resources/js/2├── components/ # Reusable Vue components3├── composables/ # Vue composables / hooks4├── layouts/ # Application layouts5├── lib/ # Utility functions and configuration6├── pages/ # Page components7└── types/ # TypeScript definitions
resources/js/
├── components/ # R... | starter-kits | 12 |
73 | Starter Kits | Vue | To publish additional shadcn-vue components, first find the component you want to publish. Then, publish the component using npx: | 1npx shadcn-vue@latest add switch
npx shadcn-vue@latest add switch | starter-kits | 12 |
74 | Starter Kits | Vue | In this example, the command will publish the Switch component to resources/js/components/ui/Switch.vue. Once the component has been published, you can use it in any of your pages: | 1<script setup lang="ts">2import { Switch } from '@/Components/ui/switch'3</script>4 5<template>6 <div>7 <Switch />8 </div>9</template>
<script setup lang="ts">
import { Switch } from '@/Components/ui/switch'
</script>
<template>
<div>
<Switch />
</div>
</template> | starter-kits | 12 |
75 | Starter Kits | Vue | The Vue starter kit includes two different primary layouts for you to choose from: a "sidebar" layout and a "header" layout. The sidebar layout is the default, but you can switch to the header layout by modifying the layout that is imported at the top of your application's resources/js/layouts/AppLayout.vue file: | 1import AppLayout from '@/layouts/app/AppSidebarLayout.vue'; 2import AppLayout from '@/layouts/app/AppHeaderLayout.vue';
import AppLayout from '@/layouts/app/AppSidebarLayout.vue';
import AppLayout from '@/layouts/app/AppHeaderLayout.vue'; | starter-kits | 12 |
76 | Starter Kits | Vue | The sidebar layout includes three different variants: the default sidebar variant, the "inset" variant, and the "floating" variant. You may choose the variant you like best by modifying the resources/js/components/AppSidebar.vue component: | 1<Sidebar collapsible="icon" variant="sidebar"> 2<Sidebar collapsible="icon" variant="inset">
<Sidebar collapsible="icon" variant="sidebar">
<Sidebar collapsible="icon" variant="inset"> | starter-kits | 12 |
77 | Starter Kits | Vue | The authentication pages included with the Vue starter kit, such as the login page and registration page, also offer three different layout variants: "simple", "card", and "split". To change your authentication layout, modify the layout that is imported at the top of your application's resources/js/layouts/AuthLayout.v... | 1import AuthLayout from '@/layouts/auth/AuthSimpleLayout.vue'; 2import AuthLayout from '@/layouts/auth/AuthSplitLayout.vue';
import AuthLayout from '@/layouts/auth/AuthSimpleLayout.vue';
import AuthLayout from '@/layouts/auth/AuthSplitLayout.vue'; | starter-kits | 12 |
78 | Starter Kits | Livewire | Our Livewire starter kit is built with Livewire 3, Tailwind, and Flux UI. As with all of our starter kits, all of the backend and frontend code exists within your application to allow for full customization. The majority of the frontend code is located in the resources/views directory. You are free to modify any of the... | 1resources/views2├── components # Reusable Livewire components3├── flux # Customized Flux components4├── livewire # Livewire pages5├── partials # Reusable Blade partials6├── dashboard.blade.php # Authenticated user dashboard7├── welcome.blade.php # Guest user ... | starter-kits | 12 |
79 | Starter Kits | Livewire | The frontend code is located in the resources/views directory, while the app/Livewire directory contains the corresponding backend logic for the Livewire components. The Livewire starter kit includes two different primary layouts for you to choose from: a "sidebar" layout and a "header" layout. The sidebar layout is th... | 1<x-layouts.app.header>2 <flux:main container>3 {{ $slot }}4 </flux:main>5</x-layouts.app.header>
<x-layouts.app.header>
<flux:main container>
{{ $slot }}
</flux:main>
</x-layouts.app.header> | starter-kits | 12 |
80 | Starter Kits | Livewire | The authentication pages included with the Livewire starter kit, such as the login page and registration page, also offer three different layout variants: "simple", "card", and "split". To change your authentication layout, modify the layout that is used by your application's resources/views/components/layouts/auth.bla... | 1<x-layouts.auth.split>2 {{ $slot }}3</x-layouts.auth.split>
<x-layouts.auth.split>
{{ $slot }}
</x-layouts.auth.split> | starter-kits | 12 |
81 | Starter Kits | Configuring Your WorkOS Starter Kit | After creating a new application using a WorkOS powered starter kit, you should set the WORKOS_CLIENT_ID, WORKOS_API_KEY, and WORKOS_REDIRECT_URL environment variables in your application's .env file. These variables should match the values provided to you in the WorkOS dashboard for your application: | 1WORKOS_CLIENT_ID=your-client-id2WORKOS_API_KEY=your-api-key3WORKOS_REDIRECT_URL="${APP_URL}/authenticate"
WORKOS_CLIENT_ID=your-client-id
WORKOS_API_KEY=your-api-key
WORKOS_REDIRECT_URL="${APP_URL}/authenticate" | starter-kits | 12 |
82 | Starter Kits | Inertia SSR | The React and Vue starter kits are compatible with Inertia's server-side rendering capabilities. To build an Inertia SSR compatible bundle for your application, run the build:ssr command: | 1npm run build:ssr
npm run build:ssr | starter-kits | 12 |
83 | Starter Kits | Inertia SSR | For convenience, a composer dev:ssr command is also available. This command will start the Laravel development server and Inertia SSR server after building an SSR compatible bundle for your application, allowing you to test your application locally using Inertia's server-side rendering engine: | 1composer dev:ssr
composer dev:ssr | starter-kits | 12 |
84 | Starter Kits | Community Maintained Starter Kits | When creating a new Laravel application using the Laravel installer, you may provide any community maintained starter kit available on Packagist to the --using flag: | 1laravel new my-app --using=example/starter-kit
laravel new my-app --using=example/starter-kit | starter-kits | 12 |
85 | Starter Kits | Frequently Asked Questions | Every starter kit gives you a solid starting point for your next application. With full ownership of the code, you can tweak, customize, and build your application exactly as you envision. However, there is no need to update the starter kit itself. Email verification can be added by uncommenting the MustVerifyEmail imp... | 1<?php 2 3namespace App\Models; 4 5use Illuminate\Contracts\Auth\MustVerifyEmail; 6// ... 7 8class User extends Authenticatable implements MustVerifyEmail 9{10 // ...11}
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
// ...
class User extends Authenticatable implements MustVerifyEma... | starter-kits | 12 |
86 | Starter Kits | Frequently Asked Questions | After registration, users will receive a verification email. To restrict access to certain routes until the user's email address is verified, add the verified middleware to the routes: | 1Route::middleware(['auth', 'verified'])->group(function () {2 Route::get('dashboard', function () {3 return Inertia::render('dashboard');4 })->name('dashboard');5});
Route::middleware(['auth', 'verified'])->group(function () {
Route::get('dashboard', function () {
return Inertia::render('dashb... | starter-kits | 12 |
87 | Starter Kits | Frequently Asked Questions | Email verification is not required when using the WorkOS variant of the starter kits. You may want to customize the default email template to better align with your application's branding. To modify this template, you should publish the email views to your application with the following command: | 1php artisan vendor:publish --tag=laravel-mail
php artisan vendor:publish --tag=laravel-mail | starter-kits | 12 |
88 | Deployment | Nginx | If you are deploying your application to a server that is running Nginx, you may use the following configuration file as a starting point for configuring your web server. Most likely, this file will need to be customized depending on your server's configuration. If you would like assistance in managing your server, con... | 1server { 2 listen 80; 3 listen [::]:80; 4 server_name example.com; 5 root /srv/example.com/public; 6 7 add_header X-Frame-Options "SAMEORIGIN"; 8 add_header X-Content-Type-Options "nosniff"; 9 10 index index.php;11 12 charset utf-8;13 14 location / {15 try_files $uri $uri/ /index.php... | deployment | 12 |
89 | Deployment | FrankenPHP | FrankenPHP may also be used to serve your Laravel applications. FrankenPHP is a modern PHP application server written in Go. To serve a Laravel PHP application using FrankenPHP, you may simply invoke its php-server command: | 1frankenphp php-server -r public/
frankenphp php-server -r public/ | deployment | 12 |
90 | Deployment | Optimization | When deploying your application to production, there are a variety of files that should be cached, including your configuration, events, routes, and views. Laravel provides a single, convenient optimize Artisan command that will cache all of these files. This command should typically be invoked as part of your applicat... | 1php artisan optimize
php artisan optimize | deployment | 12 |
91 | Deployment | Optimization | The optimize:clear method may be used to remove all of the cache files generated by the optimize command as well as all keys in the default cache driver: | 1php artisan optimize:clear
php artisan optimize:clear | deployment | 12 |
92 | Deployment | Caching Configuration | When deploying your application to production, you should make sure that you run the config:cache Artisan command during your deployment process: | 1php artisan config:cache
php artisan config:cache | deployment | 12 |
93 | Deployment | Caching Events | You should cache your application's auto-discovered event to listener mappings during your deployment process. This can be accomplished by invoking the event:cache Artisan command during deployment: | 1php artisan event:cache
php artisan event:cache | deployment | 12 |
94 | Deployment | Caching Routes | If you are building a large application with many routes, you should make sure that you are running the route:cache Artisan command during your deployment process: | 1php artisan route:cache
php artisan route:cache | deployment | 12 |
95 | Deployment | Caching Views | When deploying your application to production, you should make sure that you run the view:cache Artisan command during your deployment process: | 1php artisan view:cache
php artisan view:cache | deployment | 12 |
96 | Deployment | The Health Route | Laravel includes a built-in health check route that can be used to monitor the status of your application. In production, this route may be used to report the status of your application to an uptime monitor, load balancer, or orchestration system such as Kubernetes. By default, the health check route is served at /up a... | 1->withRouting(2 web: __DIR__.'/../routes/web.php',3 commands: __DIR__.'/../routes/console.php',4 health: '/up', 5 health: '/status', 6)
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
health: '/status',
) | deployment | 12 |
97 | Service Container | Introduction | The Laravel service container is a powerful tool for managing class dependencies and performing dependency injection. Dependency injection is a fancy phrase that essentially means this: class dependencies are "injected" into the class via the constructor or, in some cases, "setter" methods. Let's look at a simple examp... | 1<?php 2 3namespace App\Http\Controllers; 4 5use App\Services\AppleMusic; 6use Illuminate\View\View; 7 8class PodcastController extends Controller 9{10 /**11 * Create a new controller instance.12 */13 public function __construct(14 protected AppleMusic $apple,15 ) {}16 17 /**18 * Show ... | container | 12 |
98 | Service Container | Zero Configuration Resolution | If a class has no dependencies or only depends on other concrete classes (not interfaces), the container does not need to be instructed on how to resolve that class. For example, you may place the following code in your routes/web.php file: | 1<?php 2 3class Service 4{ 5 // ... 6} 7 8Route::get('/', function (Service $service) { 9 dd($service::class);10});
<?php
class Service
{
// ...
}
Route::get('/', function (Service $service) {
dd($service::class);
}); | container | 12 |
99 | Service Container | When to Utilize the Container | Thanks to zero configuration resolution, you will often type-hint dependencies on routes, controllers, event listeners, and elsewhere without ever manually interacting with the container. For example, you might type-hint the Illuminate\Http\Request object on your route definition so that you can easily access the curre... | 1use Illuminate\Http\Request;2 3Route::get('/', function (Request $request) {4 // ...5});
use Illuminate\Http\Request;
Route::get('/', function (Request $request) {
// ...
}); | container | 12 |
100 | Service Container | Binding Basics | Almost all of your service container bindings will be registered within service providers, so most of these examples will demonstrate using the container in that context. Within a service provider, you always have access to the container via the $this->app property. We can register a binding using the bind method, pass... | 1use App\Services\Transistor;2use App\Services\PodcastParser;3use Illuminate\Contracts\Foundation\Application;4 5$this->app->bind(Transistor::class, function (Application $app) {6 return new Transistor($app->make(PodcastParser::class));7});
use App\Services\Transistor;
use App\Services\PodcastParser;
use Illuminate\... | container | 12 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 7