With PHP, Composer and Node installed, one laravel new command gives you a complete, working app you can open in your browser.
π It's like moving into a furnished flat instead of an empty plot. The walls, plumbing and wiring (routing, database, security) are already in; you just bring your own furniture (your features).
A good setup saves hours later
Running in minutes
Laravel ships with sensible defaults, including a ready-to-use SQLite database. There's no server to configure before you see a page.
Tools you'll use daily
Composer, Artisan and npm are the commands you'll type every day. Getting them working now pays off in every later lesson.
Settings kept safe
The .env file keeps passwords and keys out of your code, and out of Git.
From nothing to βit works!β
laravel new.PHP 8.2+
The language Laravel is written in. Check with php -v.
Composer
PHP's package manager. It downloads Laravel and its libraries. Check with composer -V.
Node.js & npm
Builds your CSS and JavaScript with Vite. Check with node -v.
Create your first Laravel app
We'll build a project called blog, which you'll keep growing throughout the course.
-
Install the tools (the easy way: Herd)
Laravel Herd is a free desktop app for Windows and macOS. One installer gives you PHP, Composer, the Laravel installer and a local web server. It's the fastest way to start.
Download it from herd.laravel.com, run it, and open a new terminal. Then check everything is there:
php -v composer -V laravel --versionInstall Node.js (the LTS version) separately from nodejs.org if you don't already have it.
βΉοΈ Prefer to install by hand?That's fine too. Install PHP 8.2+ (with common extensions), then Composer from getcomposer.org, then add the Laravel installer globally:
composer global require laravel/installerMake sure Composer's global
vendor/binfolder is on your PATH so thelaravelcommand is found. -
Create the project
Move to the folder where you keep your code and run
laravel new. The installer asks a few questions.laravel new blog- Starter kit: choose None for now. Starter kits (React, Vue, Livewire, or the classic Breeze) add login pages; you'll meet them in Starter Kits.
- Testing framework: Pest or PHPUnit. Either is fine.
- Database: keep the default, SQLite.
- Run npm install? Yes.
No installer?
composer create-project laravel/laravel blogdoes the same job with no questions asked. -
Run the app
Step into the folder and start the development server.
php artisan servestarts PHP's built-in web server on port 8000.cd blog php artisan serveINFO Server running on [http://127.0.0.1:8000]. Press Ctrl+C to stop the serverEven better, run
composer run dev. It starts the web server, the Vite asset builder, the queue worker and a live log viewer, all in one terminal.composer run devπ‘ Using Herd?Herd automatically serves any project in its βparkedβ folder at
http://blog.test. You only neednpm run devfor your CSS/JS. -
Meet the
.envfileThe
.envfile holds settings that change between computers, such as your local machine vs. the live server. Laravel reads it on every request.APP_NAME=Blog APP_ENV=local APP_KEY=base64:Xv3...generated... APP_DEBUG=true APP_URL=http://localhost DB_CONNECTION=sqliteAPP_KEYencrypts cookies and sessions. It's generated for you; never share it.APP_DEBUG=trueshows detailed error pages. It must befalsein production.- In your code, read settings with
config('app.name'), which pulls from the files inconfig/, which in turn read.env.
β οΈ Never commit.envIt's already in
.gitignore. Commit.env.exampleinstead, a template without real secrets. A teammate copies it to.envand runsphp artisan key:generate. -
Check the database (SQLite by default)
SQLite stores the whole database in one file,
database/database.sqlite. There's no server to install. The installer has already created it and run the first migrations (the scripts that build tables).php artisan migrate:statusWant MySQL or PostgreSQL later? Change the
DB_*lines in.envand runphp artisan migrate. You'll learn more in Migrations.DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=blog DB_USERNAME=root DB_PASSWORD=
Avoid this, do that
$key = 'sk_live_123abc'; // in a controller
Secrets hard-coded in PHP files end up in Git history forever.
// .env: STRIPE_SECRET=sk_live_123abc
// config/services.php: 'secret' => env('STRIPE_SECRET'),
$key = config('services.stripe.secret');
Put secrets in .env, read them with env() in config files only, and use config() everywhere else.
Edited .env... page still shows old value π€
If you ran php artisan config:cache, Laravel stops reading .env until the cache is cleared.
php artisan config:clear
Locally, don't cache config at all. Clear it whenever .env changes seem to be ignored.
Artisan is Laravel's command-line helper. List every command it knows, or get help on one:
php artisan list
php artisan help make:controller
php artisan about
- Create a new project called
blogand open it athttp://127.0.0.1:8000(orhttp://blog.testwith Herd). - Change
APP_NAMEin.envto βMy Blogβ and print it with{{ config('app.name') }}inresources/views/welcome.blade.php. - Run
php artisan aboutand find your PHP version, Laravel version and database driver. - Stop the server, then start it again with
composer run devand see the extra processes it runs.
Key takeaways
- You need PHP 8.2+, Composer and Node.js. Laravel Herd bundles most of it.
composer global require laravel/installer, thenlaravel new blog, creates a project.php artisan serveruns the app;composer run devruns the server, Vite, queue and logs together..envholds per-machine settings and secrets. Never commit it.- New apps use SQLite by default, so you have a working database with zero setup.