Pollen Solution Standalone project skeleton.

Installs: 35

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:Shell

Type:project

v1.0.20 2022-12-29 00:00 UTC

README

Latest Stable Version MIT Licensed PHP Supported Versions

Skeleton Component provides structures of standalone project based on Pollen Solutions suite.

Table of contents

Features

The Pollen solutions Skeleton component embeds :

  • Composer, as package manager for PHP libraries.
  • ViteJS as assets bundler and responsible for compiling, transpilating, versioning, optimizing ...
  • Pollen solutions components suite that includes :
    • A dependency injection container
    • A routing system
    • A templating library
    • An asset manager and injector
    • An expandable command line interface
    • An event manager
    • ...
  • A preconfigured Docker environment integrating :
    • A light-weight command-line interface for interact with Docker easily
    • A PHP server that run through Apache
    • A MySQL server
    • An email previewer service (MailHog)
    • A sharing local application service
    • ...
  • ... And a lot of other kinds of magic !

To try it is already to contribute, you are welcome !

Installation

Standard installation

Prerequisite

Launch installation

composer create-project pollen-solutions/skeleton your-app-name

Serve the app

Serve your application using the built-in web server in PHP (or your server of choice) from the public directory:

php -S 127.0.0.1:8000 -t public

Visit the application in the browser:

Docker installation

Prerequisite

Launch installation

composer create-project pollen-solutions/skeleton your-app-name --no-install --no-scripts

Launch application builder

cd ./your-app-name

bin/app.build

Visit the application in the browser:

Retrieve More details about docker usage in a Pollen application from the built-in documentation.

Configuration

Environment configuration

During the installation process, the file .env.example is copied to .env. This file contains all required default configuration.

# ENVIRONMENT
APP_ENV=dev
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
APP_TIMEZONE=Europe/Paris

# DATABASE
DATABASE_URL=sqlite:///%%app.base_dir%%/var/database.sqlite

Customize a local environment configuration

To customize your application configuration, you can directly edit the .env file, but the best practice is to create a new .env.local file that will contain all the configuration attributes specific to your installation. Through the .env.local file you can if necessary override an environment value declared in the .env file or define new ones :

# DATABASE
DATABASE_URL=mysql://root:root@mysql:3306/pollen

#REDIS
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1

Environment variables types

STRING_VAR=string
QUOTES_VAR="quoted variable"
EMPTY_STRING=
BOOL_VAR=true
NULL_VAR=null

Environment variable mapping

You can use another existing global or previously defined environment variable like this :

DB_USERNAME=${MYSQL_USER}
DB_PASSWORD=${MYSQL_PASSWORD}

Note that, for security reasons, global environnement variables couldn't be overridden.

Use application variable

In some special cases, you may need to access application variable to complete the configuration of your environment variables and the merge vars could help you.

The paths of the application are natively available :

  • %%app.base_dir%%: Absolute path to the root directory of the app.

  • %%app.public_dir%%: Absolute path to the public directory of the app.

Example of usage :

DATABASE_URL=sqlite:///%%app.base_dir%%/var/database.sqlite

Pollen solutions suite uses the vlucas/phpdotenv library to work. More information on its github repository.

Directory structure

The Skeleton component is a micro-framework. Like other solutions of this type, it is opinionated and its directory structure is intended to provide a starting point for creating a complete web application.

The Root directory structure

|–– bin
|–– bootstrap
|–– config
|–– docker
|–– docs
|–– (node_modules)
|–– public
|–– resources
    |–– assets
    |–– views
|–– src
|–– tests
|–– var
|–– (vendor)

The Root directory details

src

The src directory contains the core PHP code of your application.

resources

The resources directory contains the templating code. This included views and css, js, fonts, images and all other assets files.

public

The public directory contains the index.php file, which is the entry point for all requests entering your application and configures autoload.

This directory also houses the build assets such css, js, fonts, images and all other assets files.

config

The config directory, as the name implies, contains all of your application's PHP configuration files.

docs

The docs directory contains the complete documentation of the micro framework and its components. Work in progress ;)