use Phalcon\Paginator\Adapter\QueryBuilder; $builder = $this->modelsManager->createBuilder() ->columns('id, name') ->from('Robots') ->orderBy('name'); $paginator = new Paginator(array( "builder" => $builder, "limit" => 10, "page" => 1 )); $page = $paginator->getPaginate();
// $queue = new Phalcon\Queue\Beanstalk(array( 'host' => '192.168.0.21' )); // ( ) $queue->put(array('proccessVideo' => 4871)); // ( ) $queue->put( array('proccessVideo' => 4871), array('priority' => 250, 'delay' => 10, 'ttr' => 3600) ); while (($job = $queue->peekReady()) !== false) { $message = $job->getBody(); var_dump($message); $job->delete(); }
// $encryption = new Phalcon\Crypt(); $key = 'le password'; $text = 'This is a secret text'; $encrypted = $encryption->encrypt($text, $key); echo $encryption->decrypt($encrypted, $key);
// CSS $this->assets ->addCss('css/style.css') ->addCss('css/index.css'); // - js- $this->assets ->addJs('js/jquery.js') ->addJs('js/bootstrap.min.js');
<html> <head> <title>Some amazing website</title> <?php $this->assets->outputCss() ?> </head> <body> <!-- ... --> <?php $this->assets->outputJs() ?> </body> </html>
use Phalcon\Mvc\Model\ValidationFailed; try { $robot = new Robots(); $robot->name = 'Bender'; $robot->save(); } catch (ValidationFailed $e) { echo 'Reason: ', $e->getMessage(); }
$router = new Phalcon\Mvc\Router(); $router->addGet('/api/robots', array( 'module' => 'api', 'controller' => 'robots', 'action' => 'index' ))->setHostName('api.phalconphp.com');
$group = new Phalcon\Mvc\Router(); $group->setHostName('api.phalconphp.com'); $groop->addGet('/api/robots', array( 'module' => 'api', 'controller' => 'robots', 'action' => 'index' )); $groop->addGet('/api/robots/{id}', array( 'module' => 'api', 'controller' => 'robots', 'action' => 'show' )); $router->mount($group);
$collection = new Phalcon\Mvc\Micro\Collection(); // $collection ->setPrefix('/posts') ->setHandler(new PostsController()); // $collection ->setPrefix('/posts') ->setHandler('PostsController', true); $collection->get('/', 'index'); $collection->get('/edit/{id}', 'edit'); $collection->delete('/delete/{id}', 'delete'); $app->mount($collection);
git clone http://github.com/phalcon/cphalcon cd build git checkout 1.1.0 sudo ./install
Source: https://habr.com/ru/post/177691/
All Articles