Various extensions and utilities for Phalcon Framework
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
Adds nested set support to your model. Simply use trait \PhalconExt\Mvc\Model\Traits\NestedSetTrait in your model.
Can be easily attached to your console application.
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
-
Choose migrations directory
define('MIGRATIONS_DIR', '... your migrations dir ...');
-
Register dir to your loader
Without namespace usage
$loader->registerDirs([ ... , MIGRATIONS_DIR]);
With namespace usage
$loader->registerNamespaces([ ... , 'Your\\Namespace' => MIGRATIONS_DIR]);
- 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);
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!
- PhalconExt\Mvc\Db\SqlMigrations - Database migrations service directly via. SQL statements
- PhalconExt\Mvc\Db\SqlMigrations\AbstractMigration - Abstract SQL migration, all migrations must extend this class
- PhalconExt\Mvc\Model\Traits\RateLimitAccessTrait - Adds access rate limit support to target model
- PhalconExt\Mvc\Model\Traits\RateLimitLoginTrait - Adds login rate limit support to target model
- PhalconExt\Validation\Validator\Color - Validates if value is valid color
- PhalconExt\Validation\Validator\EmailDomain - Validates email domain existence via DNS
- PhalconExt\Validation\Validator\PasswordRetype - Validates if password confirmation matches password
- PhalconExt\Validation\Validator\PasswordStrength - Validates password strength
- PhalconExt\Validation\Validator\StringLengthExact - Validates exact string length
Phalcon Ext is open-sourced software licensed under the New BSD License. © David Hübner