phalcon

Phalcon\Mvc\Model::validation() and non-model validators

五迷三道 提交于 2019-12-22 13:06:31
问题 I am working on Model validation using Model::validation() call. It looks like Model::validate() only accepts validators from Phalcon\Mvc\Model\Validator namespace and crashes when Phalcon\Validation\Validator are used: class User extends Phalcon\Mvc\Model { protected $email = 'invalid @email.*'; public function validation() { // Validator from Model namespace $this->validate(new Phalcon\Mvc\Model\Validator\Uniqueness(array( "field" => "email", "message" => "The email is already registered" )

Phalcon Model find() with condition in another table

房东的猫 提交于 2019-12-22 12:43:47
问题 so I have 2 tables like this books id name status_id ------------------------------- 1 a 0 2 b 2 ... status id description --------------------- 0 borrowed 1 available 2 lost Phalcon models class Books extends ModelBase { public function initialize() { $this -> belongsTo("status_id", "Status", "id"); } } class Status extends ModelBase { public function initialize() { $this -> hasMany('id', "Books", 'status_id'); } } I would like to extract all books that has status description "lost". This is

Phalcon Router and Loader for subfolder structure getting bigger. How to set up?

▼魔方 西西 提交于 2019-12-22 07:18:07
问题 I have a quite big project that I need to program. I used to code with CodeIgniter but since they stopped maintaining the framework, I decided to switch to another. I chose Phalcon framework. The folder structure of the application that I want to implement is next: app/ controllers/ admin/ users/ UsersController.php UserGroupsController.php dashboard/ system/ another_subfolder/ AnotherSubFolderController.php production/ settings/ SettingsController.php dashboard/ flow/ another_subfolder/

Can't call indexController's actions other than indexAction in Phalcon php

半世苍凉 提交于 2019-12-22 06:35:32
问题 I have a simple project in my xampp/htdocs directory called phalcon and I have apache configured to point to that folder so that I can go to phalcon/ in my browser. The problem occurs when I try to open an index controller view other than index(default). For instance I have someAction in Index controller and in views/index I have some.phtml. If I go to phalcon/index/some I don't get the text from some.phtml outputed to the page. It's probably because it thinks as if I wan't to open

Phalcon: how to get distinct models?

孤人 提交于 2019-12-22 06:27:21
问题 Using Phalcon Model, how can I get distinct rows when get rows using the find() method. 回答1: Using builder: Basic implementation for later example: $queryBuilder = $this->getDI()->getModelsManager() ->createBuilder() ->addFrom('tableName', 't'); Distinct command: $queryBuilder->distinct('t.id'); Column thing works too, but not recommended: $queryBuilder->columns('DISTINCT(t.id) AS id') Using strictly model: // we are waiting for it, but may still not be implemented TableModel::find(array(

How can I set up a user defined function in Volt (Phalcon)

旧时模样 提交于 2019-12-21 04:18:26
问题 How can I set up a user defined function in Volt? For instance I want to call a function that would translate strings in my views as such: <div class='page-header'> <h2>{{ tr('session_login_title') }}</h2> </div> and I want the tr to map to a function \My\Locale::translate($key) 回答1: Volt functions act as string replacements and do not actually call the underlying function. Volt translates the function into the relevant string which in return is interpreted by PHP. Suppose you have a Locale

how to install phalcon.so in mac os

故事扮演 提交于 2019-12-21 03:39:31
问题 I have installed phalcon extension.It was installed successfully but the phalcon command not working. following Error shown. "iMac:project Atomix$ phalcon -sh: phalcon: command not found" I have Followed instruction from Phalcon official website.it works on windows and Linux perfectly but not in mac os. 回答1: Install Phalcon in Mac OS X from Scratch Keep in mind that Phalcon is a PHP Framework that improves the power of PHP, it means that Phalcon needs an Apache Web Server running PHP and a

How to connect multiple database in phalcon framework at the same time use both in model class not only one

微笑、不失礼 提交于 2019-12-21 02:51:22
问题 In my code I have two database ABC and XYZ . I want to use both database in same model than What is the solution for it in phalcon? How to implement multiple database connection for this ? 回答1: one <?php //This service returns a MySQL database $di->set('dbMysql', function() { return new \Phalcon\Db\Adapter\Pdo\Mysql(array( "host" => "localhost", "username" => "root", "password" => "secret", "dbname" => "invo" )); }); //This service returns a PostgreSQL database $di->set('dbPostgres', function

How can I add volt syntax checking in PHPStorm

旧街凉风 提交于 2019-12-20 08:56:14
问题 I want to be able to have syntax highlighting in PHPStorm for Volt, Phalcon's template engine. Is there a way to do so? 回答1: In PHPStorm, click File -> Settings On the left side of the options click Editor -> File Types On the list that appears on the right, scroll down and select Twig In the bottom panel, click the + button to add a new wildcard and add *.volt Click OK and then OK again. 回答2: Right click on a .volt file in the project tab. Click on associate with a file type . Choose twig .

Phalcon and nginx - framework run only indexController

不打扰是莪最后的温柔 提交于 2019-12-20 03:56:01
问题 I am using Phalcon and Nginx, and i have a problem. When I go to http://myapp.dev/segmentation Phalcon should run SegmentationController and its indexAction() method. But instead, Phalcon is running IndexController(default controller for "/"). I think problem is with Nginx configuration, because all works fine under Apache. Here is my Nginx site configuration: server { listen 80; server_name myapp.dev; index index.php index.html index.htm; set $root_path '/var/www/myapp/public'; root $root