Home
Quick start
Documentation
Forum
GitHub
Home
Quick start
Documentation
Forum
GitHub

Phico is in BETA

Phico is currently in BETA, this means breakage is expected and not all project packages are public.

Quick start

It's simple to get going with Phico, here's the quick version, read on for the details.

TL;DR

git clone git@github.com:phico-php/app.git
composer init
composer serve

Clone one of the app skeletons

Phico offers three starter skeletons, they are minimally different so it doesn't matter too much which one you start with.

Every skeleton includes an identical suggested filesystem:

  • app-lite pulls in the minimal required packages.
  • app pulls in all required and recommended packages.
  • app-example pulls in all required and recommended packages and provides additional code examples.

If it's your first time installing Phico then try the app-example install

git clone git@github.com:phico-php/app-example.git

Choose app-lite if you prefer to choose other packages.

git clone git@github.com:phico-php/app-lite.git

Choose app if you want to use the Phico library packages (Recommended):

git clone git@github.com:phico-php/app.git

The suggested file structure

Each of the above skeletons provides the following folder structure:

app/                -- Application code, actions, controllers, events, models ...
boot/               -- All setup files live here
    container.php   -- define your complex objects here
    events.php      -- app event listeners live here
    functions.php   -- override the built in Phico functions
    middleware.php  -- app middleware lives here
    routes.php      -- app routes live here
config/             -- All config files live here
    app.php         -- configure app variables
    container.php   -- set container path and options
    logger.php      -- set logger level and filepath
    view.php        -- set view renderer and options
public/             -- Ensure your server webroot is pointing here
    favicon.ico     -- Avoids spamming logs with 404s
    index.php       -- entry point to the app
storage/            -- All writes are contained here, make sure permissions are set correctly
    logs/           -- check here for the app logs
    uploads/        -- temporary storage for uploaded files
    views/          -- view templates are cached here
boot.php            -- sets up the environment and starts Phico

NOTE: You are free to to follow any structure you prefer by adjusting the index.php file and boot.php files as needed for your application.

Storage permissions

Note: Ensure the storage folder can be written to by the webserver account.

Initialise the app

Creates the inital .env file and generates a unique application key

composer init

Create your first route

Open the boot/routes.php file, normally you might want to include other routes files here.

For now we'll create a simple hello world example route which returns a JSON response.

# /app/routes.php
$app->get('/hello/{name}', function ($request) {

    return response()->json([
        'status' => 'ok',
        'message' => "Hello {$name}"
    ]);

});

Serve the app

Serve the app using the built-in PHP websever

composer serve

Check it in your browser here

Next steps

Once you have your app install working you might want to familiarise yourelf with the core code and the available library packages in the documentation.

Last Updated:
Contributors: indgy