2017 © Pedro Peláez
 

project chip-modules

Components to build a PHP Micro-Framework.

image

jmrg/chip-modules

Components to build a PHP Micro-Framework.

  • Friday, February 9, 2018
  • by jmrg
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Chip-modules

Build Status, (*1)

Chip-modules is a set libraries that encapsulate their implementations to way easy and faster and provides the methods to access in an only step., (*2)

Components

This includes handlers for: - Klein - Router, controllers, and endpoints. - Symfony Config - Configuration from environment file. - Eloquent - Database and models. - Hoa Session - Session handler. - Blade - Template manager and views. - PHPMailer - Full manager to send emails., (*3)

Installing Chip-modules Composer

You can install Chip-modules into your project using Composer. For existing applications you can run the following: ``` bash $ composer require jmrg/chip-modules:"~0", (*4)



## Usage Instructions #### Environment Config To configure the params of the environment to create a file YAML like this with the database connection and parameters of SMTP: ```yaml # There are file for example named example.environment.yaml databases: prod: driver: mysql host: localhost database: database username: root password: secret charset: utf8 collation: utf8_unicode_ci mail: # 0 = off | 1 = Client messages | 2 = Client and server messages debug: 2 # Basics driver: smtp host: smtp.mailtrap.io port: 2525 username: null password: null # Encryption system: tls, ssl (deprecated) encryption: null

After that, we shoulder load the file., (*5)

// Load file...
ConfigModule::init('path/to/file/config.yaml');

// Getting config...
$c = config(); // Return the config as array.

Router Config

To configure the router we make the following:, (*6)

// Creates a new object to the configuration.
$config = new \Chip\Modules\Router\RouterConfig();
$config->setBaseNamespace("\\Namespace\\to\\controllers") // Namespace source path.
    ->attachRouterFiles('path/to/endpoints/router.php'); // Location for the file router.

// Dispatch resquest.
$r = \Chip\Modules\Router\Router::up($config);
$r->dispatch();

Example using router:, (*7)

// File router.php

// Methods availables according to HTTP verbs: get(), post(), put(), pat(), delete(), options().
$router->get('/hellow-world', function () {
    return 'Hellow World!!';
});

// To response multiple HTTP verbs:
$router->match(['get', 'post'], '/hellow-world', function () {
    return 'Hellow World!!';
});

Databases and Model Config

To configure databases we make the following:, (*8)

// In the file configuration environment, we have a sections with the
// connections to the different databases, we only must send
// a connections name to configure de database.

\Chip\Modules\Model\Manager::db('nameDatabase');

// In the case of models, these must extend from \Chip\Modules\Model\Model
class User extend \Chip\Modules\Model\Model
{
    // Something code..
}

Session Config

To configure session we make the following:, (*9)

// Recomended to use name "guest" for the session.
\Chip\Modules\Session\Session::of('Guest'); 

// To get the session to use a guest() method.
// This returns an instance of Hoa Session. Check out the documentation
// of lirary for any information https://github.com/hoaproject/Session
$session = guest();

Views and Blade Config

To configure the blade manager template we make the following:, (*10)

// Define path to views and cache.
ViewComponent::config(
    '/path/to/source/views',
    '/path/to/cache'
);

// Load the view...
view(
    'name-view',
    ['param1' => 'Hello', 'param2' => 'World!!']
);

// To build views check out the documentation https://laravel.com/docs/5.1/blade

Email Config

To configure the first that we make is fill the environment file with the params require:, (*11)

# There are file for example named example.environment.yaml

mail:
    # 0 = off | 1 = Client messages | 2 = Client and server messages
    debug: 2

    # Basics
    driver: smtp
    host: smtp.mailtrap.io
    port: 2525
    username: null
    password: null

    # Encryption system: tls, ssl (deprecated)
    encryption: null

To get a instance the handler email we make follow:, (*12)

// Create a new isntance Mailer class.
$mailer = \Chip\Modules\Mailer\Mailer::create();

// To send emails or making config aditionals check out the documentation https://github.com/PHPMailer/PHPMailer

Test

This project use PHPUnit to make test. To execute the test run the follow command:, (*13)

$ vendor/bin/phpunit

The Versions

09/02 2018

dev-master

9999999-dev

Components to build a PHP Micro-Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php micro-framework fast components chip

09/02 2018

v1.0.0

1.0.0.0

Components to build a PHP Micro-Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php micro-framework fast components chip

09/02 2018

dev-develop

dev-develop

Components to build a PHP Micro-Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php micro-framework fast components chip