phalcon

Volt not including file if path is concatenated

若如初见. 提交于 2019-12-06 13:43:27
I'm trying to iterate through a Model collection in volt: {% if model.elements|length > 0 %} {% for element in model.getElements() %} {% include "partials/panels/edit-" ~ element.getType() ~ ".volt" %} {% endfor %} {% endif %} The type can be text or images. If i use the above code, i get the error: View '/path/to/phalcon/apps/frontend/views/partials/panels/edit-image.volt' was not found in the views directory I'm sure that the file exists, since if i changethe include, it'll work: {% include "partials/panels/edit-image.volt" %} It'll also fail on: {% include "partials/pandels/edit-" ~ "image

getting exception : Service 'db' wasn't found in the dependency injection container in Phalcon

江枫思渺然 提交于 2019-12-06 12:45:36
Even after setting "db" in services.php I'm getting above exception. services.php $di->set('db', function() use ($config) { $dbclass = 'Phalcon\Db\Adapter\Pdo\\' . $config->database->adapter; return new $dbclass(array( "host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name )); }); I'm trying to fetch users from my table like this, $user = Users::findFirst(1); That time, it is giving Service 'db' wasn't found in the dependency injection container in Phalcon ::::::::::::::::::::::::::::::::::

Phalcon Multi-Module Routing

耗尽温柔 提交于 2019-12-06 11:28:00
问题 Im attempting to use the multi module configuration for the Phalcon PHP Framework. Im having an issue relating to the routing as one of my modules is inaccessible via url. It seems every time I try to access the defined modules uri, it tries to invoke the default modules namespace. Project\Module1\Controllers\Module2Controller handler class cannot be loaded The idea solution url.com/module1 => module1 url.com/moudle2 => module2 url.com => module1 In working to resolve this problem, I have

Phalcon backup view path

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 08:49:06
Is there any way to pass through a secondary path to the views dir in phalcon? in zend framework I think the syntax is $this->view->addScriptPath('/backup/path'); $this->view->addScriptPath('/preferred/path'); so if there is a file in the preferred path it will use it, if not it will fallback through the chain. I use this, for example, for mobile versions when most of the pages are the same, but some have to be significantly different and I don't want to have to duplicate all the views just for 2 or 3 variants In phalcon I have tried sending an array to the view, but that just results in

PHP / Phalcon - Automatically nesting objects

↘锁芯ラ 提交于 2019-12-06 08:06:26
Say I have three tables: CREATE TABLE divisions { idDivision INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR (40) NOT NULL } CREATE TABLE clubs { idClub INT NOT NULL AUTO_INCREMENT PRIMARY KEY, idDivision INT NOT NULL, name VARCHAR(40) NOT NULL } CREATE TABLE footballers ( idFootballer INT NOT NULL AUTO_INCREMENT PRIMARY KEY, idClub INT NOT NULL, name VARCHAR (40) NOT NULL ) And I have some lovely Phalcon models to represent those. Now, what I would like to do is do this: $divisions = new Divisions(); print json_encode($divisions::findFirst(), JSON_NUMERIC_CHECK); And that return a JSON

Phalcon VS Spring 用法对照表(一)

…衆ロ難τιáo~ 提交于 2019-12-06 06:43:31
Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | Email Phalcon VS Spring http://www.netkiller.cn/journal/phalcon.spring.html Mr. Neo Chen (陈景峯), netkiller, BG7NYT 中国广东省深圳市龙华新区民治街道溪山美地 518131 +86 13113668890 < netkiller@msn.com > 版权声明 转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。 文档出处: http://netkiller.github.io http://netkiller.sourceforge.net 微信扫描二维码进入 Netkiller 微信订阅号 QQ群:128659835 请注明“读者” 2015-11-25 摘要 Phalcon VS Spring 用法对照表 我的系列文档 编程语言 Netkiller Architect 手札 Netkiller Developer 手札 Netkiller PHP 手札 Netkiller Python 手札 Netkiller Testing 手札 Netkiller Cryptography 手札

How to find by multiple criteria with Phalcon findFirst?

…衆ロ難τιáo~ 提交于 2019-12-06 05:36:04
问题 I'm trying to get a video from my video database, the selection is based on a unique combination of external_id and language_id (both integers). I tried the following code, but it looks like findFirst() only picks up the first criterium $video = Video::findFirst("language_id=" . $language->id . " and external_id=" . $external->id); Can anybody help me how to properly use findFirst with multiple criteria? 回答1: Try binding your parameters vs. concatenating them. Safer and it might identify an

phalcon模板引擎(volt)自定义过滤器

蓝咒 提交于 2019-12-06 03:54:40
**引子:**今天遇到一个问题,模板中某些变量有时候没有定义,如果php开启了E_ALL报错级别,那么会出现一个notice,提示变量未定义。 一开始的想法是通过三元表达式(<?=isset($var)?$var:'';?>)来给每个变量设定一个默认值,后来发现这种写法太繁琐,而且与volt标签格格不入。 再后来想到屏蔽E_NOTICE报告,但开发环境下还是很不恰当的。 最后发现volt引擎有一个过滤器Filters功能,解决了这个问题,写法如:{{ var|default('str') }} ,在$var为空的时候,将会将该处设置为str,当然,str可以是空字符串。 本文就探究一下什么是过滤器,以及如何自定义过滤器。 第一,模板渲染的是什么? 在使用volt模板引擎的时候,模板是如何渲染的呢?大家都知道,在控制器方法执行完毕后,框架会自动渲染视图View,而这时候由于你使用了volt模板引擎,里面特有的一套标签语法并非php语法,所以视图无法直接include模板文件而作为php脚本解释。这时候视图会做一件事情,它会先将模板代码中的标签替换为php代码,保存到模板缓存文件中,缓存位置是你在di中配置视图的时候自己设置的,每个缓存文件都对应一个模板文件,第二次渲染视图的时候将直接取缓存文件,避免了每次都要解析volt标签,所以性能上与原生php模板并无差距,某些情况下可能更好

phalcon php built-in server Failed opening required .htrouter

最后都变了- 提交于 2019-12-06 02:42:45
Trying to run phalcon 2.0.7 app using built-in http server in php 5.6 and included .htrouter to make URI rewrite working. Everything seems find until I use die() in controller. For the first time it works as expected but when refreshed it throws PHP fatal error: Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required '.htrouter.php' (include_path='.:') in Unknown on line 0 Is there a way to fix that or should I start configuring other http server? Julius Koronci I had the .htrouter in my public dir so this helped a

How to connect multiple database in phalcon framework

别来无恙 提交于 2019-12-05 18:50:12
i have to database namely master and xyz ,in that i required to connect both database in application . so is it possible to connect multiple database in one application and yes then how.? Set your connections in DI: //This service returns a MySQL database $di->set('dbMaster', function() { return new \Phalcon\Db\Adapter\Pdo\Mysql(array( "host" => "localhost", "username" => "", "password" => "", "dbname" => "" )); }); //This service returns a PostgreSQL database $di->set('dbSlave', function() { return new \Phalcon\Db\Adapter\Pdo\Mysql(array( "host" => "localhost", "username" => "", "password" =>