Skip to content

Instantly share code, notes, and snippets.

View kargirwar's full-sized avatar

Pankaj Kargirwar kargirwar

View GitHub Profile
<?php
public function release() {
$collection = $this->collectionBuilder();
$collection->addCode([$this, 'mvCssFiles']);
$collection->addCode([$this, 'changeRefs']);
return $collection;
}
<?php
class RoboFile extends \Robo\Tasks
{
public function mvCssFiles() {
$this->taskCopyDir(["css" => "css-0.1"])->run();
$this->taskDeleteDir("css")->run();
}
public function changeRefs() {
$this->taskReplaceInFile("index.html")
<?php
public function change()
{
$table = $this->table('photographers');
$table->addColumn('created-at', 'timestamp', [
'default' => 'CURRENT_TIMESTAMP',
'after' => 'portfolio-url'])
->addColumn('updated-at', 'timestamp', [
'update' => 'CURRENT_TIMESTAMP',
'default' => 'CURRENT_TIMESTAMP',
<?php
public function change()
{
$table = $this->table('cameras');
$table->addColumn('name', 'string', ['length' => 200])
->addColumn('photographer-id', 'integer')
->addForeignKey('photographer-id', 'photographers', 'id')
->create();
}
<?php
public function change()
{
$table = $this->table('photographers');
$table->addIndex(['name', 'phone'], ['unique' => true])
->update();
}
<?php
public function change()
{
$table = $this->table('photographers');
$table->addColumn('portfolio-url', 'text', ['after' => 'phone'])
->update();
}
<?php
public function change()
{
$table = $this->table('photographers');
$table->addColumn('name', 'string', ['length' => 200])
->addColumn('phone', 'string', ['length' => 10])
->create();
}
paths:
migrations: %%PHINX_CONFIG_DIR%%/db/migrations
seeds: %%PHINX_CONFIG_DIR%%/db/seeds
environments:
default_migration_table: phinxlog
default_database: development
production:
adapter: mysql
host: localhost
<?php
public function run() {
while ($this->mWorker->work()) {
if ($this->mWorker->returnCode() != GEARMAN_SUCCESS) {
throw new \Exception("Fatal Error");
}
}
}
public function report(\GearmanJob $job) {
//simulate long running task
<?php
function __construct() {
# Create our worker object.
$this->mWorker = new \GearmanWorker();
# Add default server (localhost).
$this->mWorker->addServer();
$this->mWorker->addFunction(Client::JOB_TYPE_REPORT, [$this, "report"]);
}