Lập trình · 22/09/2026

Laravel 13 Course – Lesson 02: Install Laravel 13 and the TaskFlow Development Environment

Lesson 2 of the Laravel 13 course: prepare a working TaskFlow application with a database and a repeatable test command. This is not yet a complete task manager: it is the stable starting point for subsequent lessons. Read lesson 1: the TaskFlow roadmap first.

Cài đặt Laravel 13 và môi trường phát triển TaskFlow

Lesson 2 of the Laravel 13 course: prepare a working TaskFlow application with a database and a repeatable test command. This is not yet a complete task manager: it is the stable starting point for subsequent lessons. Read lesson 1: the TaskFlow roadmap first.

1. Choose one practical baseline

The main hands-on path uses Laravel 13, Blade and SQLite. Docker, Redis, MySQL and a separate frontend are not required yet. We will introduce additional infrastructure when a concrete lesson needs it. This separates setup failures from business-logic failures.

Laravel 13 requires at least PHP 8.3, but the dependency graph resolved for this example needs PHP 8.4 or later. Use a compatible PHP 8.4 installation with the required extensions for this course path. A framework's minimum PHP version does not guarantee that every development dependency supports that same minimum. See the Laravel deployment requirements.

ComponentVerified environmentPurpose
PHP8.4.25Application, Artisan and tests
Laravel Framework13.32.0Resolved framework dependency
Composer2.9.5PHP dependencies
Node.js / npm24.14.1 / 11.11.0Frontend tooling
Vite8.3.0Frontend asset build
DatabaseSQLite through pdo_sqliteLocal database without a separate service

These are observed versions, not a promise that a fresh installation months later resolves identically. Preserve lock files to reproduce dependencies. Check the Vite guide for Node compatibility when using another Node major.

2. Verify the terminal environment

php -v
php --ini
php -m
composer --version
node --version
npm --version
git --version

In PowerShell, use Get-Command php and Get-Command composer to identify executables. On macOS or Linux, use command -v php. Terminal PHP may differ from Apache, Herd or container PHP. An old XAMPP PHP 8.2 cannot install this Laravel version merely because it still serves an older website successfully.

Check extensions including OpenSSL, Mbstring, PDO, Fileinfo, DOM/XML, Ctype, Tokenizer and pdo_sqlite; curl and zip are useful for installing packages. Read the loaded configuration path before editing php.ini. On Windows, match PHP's architecture and Visual C++ runtime requirements. Use the official runtime distribution if needed; do not download individual DLLs from untrusted sites.

3. Create TaskFlow in a new directory

The commands assume compatible PHP is on PATH. Run them from a parent directory where taskflow does not already contain important files:

composer create-project laravel/laravel taskflow "^13.0" --prefer-dist
cd taskflow
php artisan --version
composer check-platform-reqs

This Composer skeleton approach was used for the verified example. The official installation guide also provides an interactive installer. Pick one creation method, not both in the same directory. We deliberately postpone a starter kit until the underlying structure is understood.

For a version conflict, identify which package requires which PHP version. Do not hide incompatibility with --ignore-platform-reqs. For TLS download failures, check the CA bundle and system clock instead of disabling certificate verification. If Composer is still extracting dependencies, allow it to finish rather than starting a second process against the same vendor directory.

4. Configure the local database

Project creation normally prepares .env and an application key. Check that the file exists without publishing its contents. For a fresh checkout without .env, PowerShell users can run Copy-Item .env.example .env once, then php artisan key:generate. Never overwrite existing environment settings or regenerate a key for an application with encrypted data.

Set these non-secret local values while preserving the generated APP_KEY:

APP_NAME=TaskFlow
APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
DB_CONNECTION=sqlite

Use the skeleton's default SQLite path, database/database.sqlite. Remove or correct any stale DB_DATABASE setting pointing outside this project. Then run:

php artisan config:clear
php artisan migrate
php artisan migrate:status

If prompted to create the SQLite file, accept only for this dedicated local project. Expect the users, cache and jobs migrations to have run. There are no projects or tasks tables yet. Do not treat migrate:fresh as a general troubleshooting command: it drops all tables on the selected connection.

5. Build assets and run the application

npm install --ignore-scripts
npm run build
php artisan test
php artisan serve --host=127.0.0.1 --port=8000

Open http://127.0.0.1:8000. Leave the serving terminal open and stop it with Ctrl+C. Binding to loopback keeps this practice server local; it is not a production serving strategy. After package-lock.json exists, use npm ci --ignore-scripts for clean lock-based installations. The ignore-scripts option skips installation lifecycle scripts; an explicitly requested npm run build still executes the build script.

Observed verification: Laravel reported 13.32.0, all three baseline migrations had run, two skeleton tests passed with two assertions, and Vite built successfully. An optional fontaine fallback-optimization warning was not a build failure. These checks establish a working skeleton, not completed TaskFlow features or load capacity.

When editing frontend code in later lessons, run npm run dev in another terminal for fast asset updates. For a missing manifest error, check that the build ran in the correct directory. If the browser tries to contact a stopped Vite server, inspect the development server and hot-file state before assuming Laravel is broken.

6. Diagnose common failures

  • Could not find driver: inspect pdo_sqlite using the same PHP executable as Artisan, enable it and restart the process.
  • No application encryption key: for a new local application, check .env and generate the key; clear cached configuration if necessary.
  • Unable to open database file: inspect the SQLite path, file and directory write permissions.
  • Port 8000 is occupied: use 8001 and adjust the browser URL rather than terminating an unidentified process.
  • HTTP 500: read the latest relevant storage/logs entry, but do not share logs containing tokens, cookies or personal information.
  • Composer uses old PHP: deliberately adjust PATH or invoke composer.phar with the newer PHP executable, then verify php -v again.

7. Exercise and completion criteria

Create your own project and record versions, migration status, test and build results in a secret-free learning note. Explain why Composer and npm are different steps, why SQLite needs a PDO driver, and why composer.lock and package-lock.json belong in version control.

Do not commit .env, vendor, node_modules, local databases or public/build when the repository's deployment workflow builds assets in CI. Keep .env.example free of secrets so another developer can discover required settings. Finish this lesson by stopping the server, opening a new terminal and successfully starting the application again while explaining each step.

Navigation: Lesson 1 — Roadmap. The next lesson follows the project structure and request lifecycle before adding TaskFlow business features.

Laravel 13 course navigation

Previous lesson (01) · Next lesson (03) · All 37 lessons

Discussion

Comments 0

Sign in to comment

You need an account to join the discussion and reply to other readers.

Sign inRegister

No comments yet. Be the first to share your thoughts.