Originally published on php-apps.learnio.dev — part of the Using Native PHP course. View this lesson on the original site.

Your app starts as Laravel

Everything you ship in this course begins as a normal Laravel application. Routes, controllers, Eloquent models, Blade views, migrations, queues — the same patterns you already know or are learning now. NativePHP Mobile wraps that Laravel app and runs it on a phone. You are not learning a separate mobile framework from scratch; you are extending a Laravel project until it lives on device.

This lesson gets that Laravel project onto your machine and running in the browser. Chapter 2 adds NativePHP, Jump, and your first native run. For now, focus on one outcome: a fresh Laravel app you can open locally and trust as your working baseline.

What you need first

Before you pull down Laravel, confirm the basics on your machine:

php -v
composer -V

NativePHP Mobile targets modern PHP (8.3 or newer is a safe baseline for this course). If either command fails, fix your PHP and Composer setup in Chapter 2 before continuing — but most learners can scaffold Laravel now and refine the mobile toolchain later.

Useful references:

Pull down a fresh Laravel app

Pick one scaffold method. Both produce the same result: a new my-app directory with a standard Laravel tree.

Using the Laravel installer:

composer global require laravel/installer
laravel new my-app
cd my-app

Using Composer only (no global installer):

composer create-project laravel/laravel my-app
cd my-app

Copy the environment file and generate an app key — Laravel expects both before the app is usable:

cp .env.example .env
php artisan key:generate

Install front-end dependencies if you plan to use Vite during development (most Laravel apps do):

npm install

You now have a Laravel codebase on disk. The next step is choosing how you want to run it day to day.

How to run it locally — pick what suits you

There is no single correct choice. Use the option that matches your OS, your team, and how much environment setup you want to own.

Option A: Laravel Herd

Herd is the fastest path if you want Laravel handled for you. It ships PHP, nginx, and sensible defaults without manual web-server configuration. It is especially popular on macOS and is also available on Windows.

  1. Install Herd from herd.laravel.com.
  2. Create or open your project folder.
  3. Herd serves Laravel apps from configured paths automatically — or create a new app with:
herd new my-app
cd my-app

Open the URL Herd assigns (often something like http://my-app.test) and confirm you see the Laravel welcome page.

Choose Herd when you want low friction, you develop on Mac or Windows, and you are happy with Herd managing PHP versions and local domains.

Option B: Docker with Laravel Sail

Sail is Laravel's official Docker wrapper. Every service — PHP, MySQL, Redis, mail — runs in containers. That makes onboarding consistent across macOS, Linux, and Windows, and it avoids polluting your host machine with multiple PHP versions.

From inside your new Laravel project:

composer require laravel/sail --dev
php artisan sail:install

Select the services you need when prompted (database and mail are common defaults). Start the stack:

./vendor/bin/sail up

In another terminal, run Artisan through Sail:

./vendor/bin/sail artisan migrate

Visit http://localhost (Sail's default) and confirm the welcome page loads.

Choose Sail when you already use Docker, you want reproducible environments across machines, or you prefer isolating project dependencies inside containers.

Option C: Built-in PHP server (quick smoke test)

If you only need to verify the install before committing to Herd or Sail:

php artisan serve

Open http://127.0.0.1:8000. You should see Laravel's default welcome screen.

This is fine for a quick check. For daily development, most learners settle on Herd or Sail so database services, queues, and mail are not an afterthought.

flowchart TD
    A[Scaffold Laravel app] --> B{How will you run it?}
    B -->|Low setup, local domains| C[Laravel Herd]
    B -->|Containers, team parity| D[Laravel Sail]
    B -->|One-off verification| E[php artisan serve]
    C --> F[Welcome page in browser]
    D --> F
    E --> F
    F --> G[Chapter 2: add NativePHP Mobile]

Confirm it works

Before moving on, check these three things:

  1. The welcome page loads in your browser without a 500 error.
  2. php artisan --version reports a Laravel version from your project directory (or via ./vendor/bin/sail artisan --version if you use Sail).
  3. Your .env file exists and APP_KEY is set after key:generate.

If something fails, read the error in storage/logs/laravel.log first. Most first-run issues are a missing .env, an unset APP_KEY, or port 8000 already in use — try php artisan serve --port=8080.

How this connects to the mobile app

The Laravel app you just created is the foundation for the rest of the course. You will add routes and features in Laravel first, prove them in the browser, then run the same codebase on a phone with NativePHP. Keeping a working local Laravel baseline matters: when mobile behaviour looks wrong, you can always fall back to the browser and isolate whether the bug is Laravel logic or the native shell.

Chapter 2 picks up from here — adding NativePHP to your project, installing Jump on your phone, and your first on-device preview. The next lesson maps the three commands you will use every day: Jump, native:run, and native:watch.

Remember

You are building a Laravel app. Herd, Sail, and php artisan serve are three ways to run the same project — pick one that fits your machine and stick with it through the course.

From Using Native PHP — Introduction and first screen on mobile