Skip to content

davihu/phalcon-ext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phalcon Ext

Various extensions and utilities for Phalcon Framework

Pre-requisites

  1. Phalcon framework 2.x or 3.x

Installation

Using Composer

You can use the composer package manager to install. Either run:

$ php composer.phar require davihu/phalcon-ext "^1.2"

or add:

"davihu/phalcon-ext": "^1.2"

to your composer.json file

Whats new?

Version 1.2

Added nested set support

Adds nested set support to your model. Simply use trait \PhalconExt\Mvc\Model\Traits\NestedSetTrait in your model.

Version 1.1

Added SQL database migrations support

Can be easily attached to your console application.

Supported commands:
php console.php migrations generate                        # generates new migration class
php console.php migrations migrate                         # migrates database to last version
php console.php migrations migrate 160910160944            # migrates database to selected version
php console.php migrations sql > migrate.sql               # saves SQL statements for migration to last version to file migrate.sql
php console.php migrations sql 160910160944 > migrate.sql  # saves SQL statements for migration to selected version to file migrate.sql
Set up in console bootstrap file:
  1. Choose migrations directory

    define('MIGRATIONS_DIR', '... your migrations dir ...');

  2. Register dir to your loader

Without namespace usage

$loader->registerDirs([ ... , MIGRATIONS_DIR]);

With namespace usage

$loader->registerNamespaces([ ... , 'Your\\Namespace' => MIGRATIONS_DIR]);
  1. Register migrations service to DI

Without namespace usage

$di->set('migrations', function () {
    return new \PhalconExt\Db\SqlMigrations($this->get('db'), MIGRATIONS_DIR);
}, true);

With namespace usage

$di->set('migrations', function () {
    return new \PhalconExt\Db\SqlMigrations($this->get('db'), MIGRATIONS_DIR, 'Your\\Namespace');
}, true);
Writing migrations classes
use PhalconExt\Db\SqlMigrations\AbstractMigration;

class Migration160910160944 extends AbstractMigration
{
    public function up()
    {
        # simple statements
        $this->addSql("ALTER TABLE robots ADD COLUMN number VARCHAR(20)");

        # routine statements like triggers, procedures and functions
        $this->addSql("CREATE TRIGGER MyTrigger ...", true);
    }

    public function down()
    {
        $this->addSql("ALTER TABLE robots DROP COLUMN number");
        $this->addSql("DROP TRIGGER MyTrigger");
    }
}

Thats all, very simple but powerfull!

Contents

Db

Model

Validators

License

Phalcon Ext is open-sourced software licensed under the New BSD License. © David Hübner

About

Various extensions and utilities for Phalcon Framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages