Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Contents

Installation

A new project is not assembled package by package. There is a ready-made skeleton — laminas-mvc-skeleton — with the folders, configuration and a first page already in place. You need PHP 8.1 or newer and Composer, the program that downloads PHP packages.

Creating the project

Open a terminal in the folder where you keep your projects and run:

composer create-project -s dev laminas/laminas-mvc-skeleton blog

Composer creates the blog folder and downloads the skeleton into it together with the framework packages.

Installer questions

During installation you will be asked a few questions:

QuestionWhat to answer
Do you want a minimal install?Y — install only the basics; other packages are added later in the course
Please select which config file you wish to inject ... into1 — the config/modules.config.php file
Remember this option for other packages of the same type?Y — do not ask again

The second question comes from the component installer. Many Laminas packages must not only be downloaded but also added to the application's module list, and the installer does that for you.

Running

Go into the project folder and start PHP's built-in server:

cd blog
composer serve

composer serve is a shortcut for php -S 0.0.0.0:8080 -t public. Open http://localhost:8080 in the browser — the Laminas welcome page appears. Stop the server with Ctrl+C.

Development mode

Turn development mode on right away:

composer development-enable

In this mode you see the error text and its place in the code instead of a generic error message, and the configuration is not cached. composer development-status shows the current state and composer development-disable turns the mode off. The configuration lesson explains it in more detail.

What already works

After installation the project has one module — Application — with the home page. Its text lives in module/Application/view/application/index/index.phtml. Change any heading there and refresh the page in the browser: the change shows up immediately.

Common mistake

The built-in server must be started so that the public folder is the site root. If you run php -S localhost:8080 from the project root without -t public, the browser shows a file listing or a 404 error, and configuration files with passwords become reachable by a direct link. Use composer serve: the path is already correct there.

Thanks for reading!

Donate to the site — we work hard for you.