creios/creiwork

A PHP Framework build upon awesome packages

Installs: 70

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 1

Open Issues: 1

Language:HTML

v4.0.0-beta 2018-10-29 12:58 UTC

README

Creiwork Logo

Creiwork

GitHub license

A PHP Framework built upon awesome packages

Install

Composer Create-Project enables you to create a new project based on creiwork. Composer will install Creiwork and all of it's server-side dependencies.

composer create-project creios/creiwork my-new-project

Creiwork uses yar to install client-side dependencies.

yarn

Creiwork uses the directory cache to store often uses values. This directory needs permissions to be written by the webserver process.

chown www-data:www-data cache 

Creiwork uses flyway for database migrationes. Follow these commands to install flyway under Linux:

Download and untar it to /opt. (Note: you might want to check for a newer version)

https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/5.1.4/flyway-commandline-5.1.4-linux-x64.tar.gz

Create symlink to make it accessible from the command line:

sudo ln -s /opt/flyway-5.1.4/flyway /usr/local/bin/flyway

Make it executable:

sudo chmod +X /usr/local/bin/flyway

Usage

Creiwork is based on the Model-View-Controller architectural pattern. But one of the major goals of creiwork is to decouple these three layers.

Results

Results should be yield by a controller. They represent an abstract response.

  • TemplateResult
  • FileResult
  • RedirectResult
  • JsonResult
  • JsonRawResult
  • HtmlRawResult
  • XmlRawResult
  • CsvResult
  • PlainTextResult
  • StreamResult
  • StringBufferResult
  • ApacheFileResult
  • NginxFileResult

Start

Creiwork is built to work with Docker and comes with a preconfigured Docker-Setup to get your development up running as fast as possible.

To start Creiwork's Docker containers, just run:

docker-compose up

This will start The following services:

  • LEMP Stack
    • PHP 7.2 FPM
    • Nginx - Port: 8080 (HTTP) and 8443 (HTTPS)
    • MariaDB - Port: 3306
  • Dev Tools:
    • Mailcatcher - Port: 1080
  • Profiling and Performance
    • Webgrind - Port: 8081
    • xhgui - Port: 8082

If you want to install custom PHP Extension use the provided Dockerfile.

Debugging and Profiling

The Creiwork's Docker-Setup is configured to enable debugging and profiling out of the box. PHP Xdebug as well as Tideways (a modern XHProf fork) are installed inside the PHP Image.

Xdebug

Xdebug can be configured through the docker/php/creiwork.ini which holds the configuration for PHP.

To start a debugging session configure your IDE to listen for connections and use a a Browseraddon to inform the webserver that debugging/profiling should be enabled.

Xdebug profiling snapshots are stored to the tmp/xdebug folder inside the PHP container which is mounted the the folder docker/xdebug/profiling inside your project's folder on your machine. You can simply use your IDE or a third party tool to analyze the snapshots. For convenience purpose the Docker-Setup also provides a Webgrind container wich provides a webappication at 127.0.0.1:8081 to enable fast analysis of your snapshots.

Tideways (XHProf)

XHProf is a light-weight hierarchical and instrumentation based profiler. During the data collection phase, it keeps track of call counts and inclusive metrics for arcs in the dynamic callgraph of a program. It computes exclusive metrics in the reporting/post processing phase, such as wall (elapsed) time, CPU time and memory usage. A functions profile can be broken down by callers or callees.

To enable XHProf in development context with the provided Docker-Setup just go to public/index.php and uncomment the following lines:

if (file_exists('/xhgui-service/external/header.php')) {
require_once '/xhgui-service/external/header.php';
}

XHProof should then start collecting metrics of your application. You can conveniently access the collected data through the provided xhgui Docker container. Accessible under 127.0.0.1:8082. The configuration can be found in docker/xhgui/config/config.php.

XHProf is built to run in production to give you real-world data. If you want to use it in production just change the path inside the index.php.

Awesome Packages

  • Aura.Session: Tools for managing sessions, including session segments and read-once messages
  • Bootstrap: The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web
  • Bower: A package manager for the web
  • Guzzle PSR-7: PSR-7 HTTP message library
  • Monolog: Sends your logs to files, sockets, inboxes, databases and various web services
  • PHP-DI: The dependency injection container for humans
  • Phpunit: The PHP Unit Testing framework
  • Plates: Native PHP template system
  • Robo: Modern task runner for PHP
  • Routerunner: Router for HTTP-request written in PHP
  • Whoops: PHP errors for cool kids