2017 © Pedro Peláez
 

library phoundation

Framework-agnostic basis for bootstrapping PHP applications

image

nikolaposa/phoundation

Framework-agnostic basis for bootstrapping PHP applications

  • Sunday, June 25, 2017
  • by nikolaposa
  • Repository
  • 2 Watchers
  • 11 Stars
  • 1,222 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 14 % Grown

The README.md

Phoundation

![Build Status][ico-build] ![Code Quality][ico-code-quality] Code Coverage Latest Version PDS Skeleton, (*1)

Phoundation (pronounced the same way as "foundation") facilitates the routine step of bootstrapping PHP applications., (*2)

Installation

The preferred method of installation is via Composer. Run the following command to install the latest version of a package and add it to your project's composer.json:, (*3)

composer require nikolaposa/phoundation

Purpose

Bootstrapping of today's PHP applications typically comes down to:, (*4)

  1. Configuration loading
  2. Dependency Injection Container initialization

Phoundation aims to reduce the amount of repetitive code needed for the application startup logic by abstracting bootstrapping process., (*5)

Usage

Given the configuration files:, (*6)

config/global.php, (*7)

return [
    'db' => [
        'driver' => 'pdo_mysql',
        'host' => 'localhost',
        'user' => 'root',
        'password' => 'secret',
        'dbname' => 'test',
    ],
    'dependencies' => [
        'factories' => [
            \PDO::class => function () {
                return new \PDO('sqlite::memory:');
            },
            'My\\Web\\Application' => My\Web\ApplicationFactory::class,
        ]
    ],
];

config/local.php, (*8)

return [
    'db' => [
        'user' => 'admin',
        'password' => '1234',
    ],
];

Create bootstrap script which typically lives in src/bootstrap.php:, (*9)


use Phoundation\Bootstrap; use Phoundation\Config\FileConfigLoader; use Phoundation\DependencyInjection\LaminasServiceManagerFactory; $bootstrap = new Bootstrap( new FileConfigLoader(glob(sprintf('config/{{,*.}global,{,*.}%s}.php', getenv('APP_ENV') ?: 'local'), GLOB_BRACE)), new LaminasServiceManagerFactory() ); return $bootstrap();

Load bootstrap in your web application root (for example public/index.php):, (*10)


/* @var \Psr\Container\ContainerInterface $diContainer */ $diContainer = require __DIR__ . '/../src/bootstrap.php'; $diContainer->get('My\\Web\\Application')->run();

Credits

License

Released under MIT License - see the License File for details., (*11)

The Versions

25/06 2017

dev-master

9999999-dev

Framework-agnostic basis for bootstrapping PHP applications

  Sources   Download

MIT

The Requires

 

The Development Requires

config bootstrap foundation application di basis

25/06 2017

2.0.0

2.0.0.0

Framework-agnostic basis for bootstrapping PHP applications

  Sources   Download

MIT

The Requires

 

The Development Requires

config bootstrap foundation application di basis

14/06 2017

1.1.0

1.1.0.0

Framework-agnostic basis for bootstrapping PHP applications

  Sources   Download

MIT

The Requires

 

The Development Requires

config bootstrap foundation application di basis

14/06 2017

1.1.x-dev

1.1.9999999.9999999-dev

Framework-agnostic basis for bootstrapping PHP applications

  Sources   Download

MIT

The Requires

 

The Development Requires

config bootstrap foundation application di basis

04/03 2017

1.0.0

1.0.0.0

Framework-agnostic basis for bootstrapping PHP applications

  Sources   Download

MIT

The Requires

 

The Development Requires

config bootstrap foundation application di basis

26/02 2017

0.1.0

0.1.0.0

Framework-agnostic basis for bootstrapping PHP applications

  Sources   Download

MIT

The Requires

 

The Development Requires

config bootstrap foundation application di basis