PHPackages                             f4php/f4 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. f4php/f4

ActiveProject[Framework](/categories/framework)

f4php/f4
========

The skeleton application for F4, a (really) lightweight web application framework

v0.1.0(1mo ago)114↓100%MITPugPHP ^8.4.1

Since Dec 15Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/f4php/f4)[ Packagist](https://packagist.org/packages/f4php/f4)[ RSS](/packages/f4php-f4/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (12)Used By (0)

Introduction
============

[](#introduction)

This is a default skeleton Web Application that uses F4, a lightweight PHP/PostgreSQL-based web development framework.

Requirements
============

[](#requirements)

To configure and run your app using F4 you will need:

- composer
- node/npm
- php version 8.4.1 or higher
- postgresql version 16 or higher

Quick start
===========

[](#quick-start)

To start developing your app called `myapp` with F4, use the following composer command:

```
composer create-project f4php/f4 myapp

```

and... that's it, you are good to go!

Proceed by starting a developemnt server and playing with included Tutorial app.

Development Server
==================

[](#development-server)

To run both the built-in PHP development web server and Vite development server, just enter the app folder and run the `npm run dev` command:

```
cd myapp

```

```
npm run dev

```

You can now open  in your browser and proceed with the included Tutorial app.

More Technical Details on Development Server
--------------------------------------------

[](#more-technical-details-on-development-server)

The command above has the same effect as running these two commands concurrently:

```
composer run serve
vite

```

By default, `composer run serve` uses `local` environment configuration (note that the concept of F4 environments is explained below), which starts the PHP dev server at `http://localhost:8080`.

To change the host and port configurations, please refer to `composer.json` for PHP dev server and `vite.config.js` for Vite dev server, both files can be found in project root directory.

Configuring your project
========================

[](#configuring-your-project)

F4 relies on the concept of *environments* to determine how to initialize configuration parameters for your server application.

Environment definitions are read by `F4\Loader` from the main `composer.json` file as an `extra.f4.environments` property.

Each environment must have a name, must be an object and include at least one "config" property, specifying path to a .php file that holds relevant configuration parameters for each environment.

At runtime, F4 will look for `F4_ENVIRONMENT` process variable to decide which environment to use when locating and loading the main configuration file. If no such environment name is specified, it will try the names of `local` and `default` in that particular order.

This is an example of a `local` environment definition taken from `composer.json`:

```
...
  "extra": {
    "f4": {
      "environments": {
        "local": {
          "config": "config/local.php"
        }
      }
    }
  }
```

All configuration parameters must be implemented as public constants of a `F4\Config` class. This is a very simple example of a `config/local.php` file that redefines `MODULES` constant:

```
