phalcon

How to install phalcon version 2

落爺英雄遲暮 提交于 2019-12-12 22:36:48
问题 I have some applications built on phalcon version 2, but since the release of the version 3, new installations of phalcon default to version 3. 回答1: You need to install phalcon from source, but instead of build from the master branch switch the branch to the 2.0.x branch. git clone --depth 1 https://github.com/phalcon/cphalcon.git cd cphalcon git remote set-branches origin '2.0.x' git fetch --depth 1 origin 2.0.x git checkout 2.0.x cd build ./install I created this gist to make this easier -

Phalcon - Implement One-To-Many self-referencing relationship in model

妖精的绣舞 提交于 2019-12-12 05:42:00
问题 How to implement this feature in the Phalcon? Doctrine has this. I want something similar like that. My office table in the database: Id (PK) | ParentId | Name I want a function like: Office::findFirst()->children(); I've tried to define a Many-to-One relationship in my model but it always returns an empty array. 回答1: In your model: namespace Models; class ProductCategories extends BaseModel public function initialize() { $this->hasMany('id', 'Models\ProductCategories', 'parent_id', [ 'alias'

Image resources with Phalcon

十年热恋 提交于 2019-12-12 05:39:23
问题 I have the following code in my stylesheet: body { margin: 1cm 3cm 1cm; background-image:url("bg.png"); background-position:center top; background-repeat:no-repeat; } But the background isn't found on the server. I have tested this code with just a basic html page and it does work, there must be something that isn't allowing it within the Phalcon framework. Possibly the file location of the image? I have it in the same folder as the html file. 回答1: Yes, I believe that the location of your

phalcon - Relationships not defined when converting resultset to array?

醉酒当歌 提交于 2019-12-12 05:17:21
问题 I have tested it with 2 methods: The first: class ProjectsController extends ControllerBase { public function indexAction() { $row = array(); $projects = Projects::find(); foreach ($projects as $project) { foreach($project->employees as $employee){ echo "Employee: " . $employee->name; } } exit; } } Output: Employee: Admin The second: class ProjectsController extends ControllerBase { public function indexAction() { $row = array(); $projects = Projects::find(); $projects = $projects->toArray();

PHP Phalcon Routing with file extension

我与影子孤独终老i 提交于 2019-12-12 04:22:01
问题 In my PHP Phalcon 3 Application I have a custom route: $router->add("/{chapter}/{name}.{type:[a-z]+}", array( "controller" => 'images', "action" => 'getFile', )); I test the application local with PHP Builtin Server, other routes are working regulary. If i test the route above: http://localhost:8000/XYZ/test.jpg I always get a 404. But in regards to the documentation it should work: https://docs.phalconphp.com/en/latest/reference/routing.html Do you have any idea whats wrong? This is my

modelsManager not set in Phalcon Unittest

旧城冷巷雨未停 提交于 2019-12-12 04:18:35
问题 I'm integrating PHPUnit in my Phalcon project. I had it running correctly in MAMP, but when I run phpunit on my server, I keep getting some errors. This is UnitTestCase: <?php use \Phalcon\Di; use \Phalcon\DI\FactoryDefault; use \Phalcon\Test\UnitTestCase as PhalconTestCase; use \Phalcon\Mvc\View; use \Phalcon\Crypt; use \Phalcon\Mvc\Dispatcher; use \Phalcon\Mvc\Dispatcher as PhDispatcher; use \Phalcon\Mvc\Url as UrlResolver; use \Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use \Phalcon\Mvc

How to render code in phalcon view

北慕城南 提交于 2019-12-12 02:33:18
问题 $view->start(); $view->render("products", "list"); $view->finish(); above is show how to render from a file, I wonder is it possible to render a string/code with this method? $view->start(); $view->renderstring("<?php echo $this->url->get('users/list') ?>"); $view->finish(); 回答1: You can use 'setContent' to set the view content: $view->setContent('<h1>hello</h1>'); But this functions receives the final content to the view. So to do the example you gave the correct use would be: $output = 'The

Appending multiple config arrays in PhalconPHP

风流意气都作罢 提交于 2019-12-11 13:49:57
问题 Currently I am loading multiple config files containing PHP native arrays, within my bootstrap. require "app/configuration/config-global.php"; require "app/configuration/config-other.php"; With this setup "config-other.php" is overwriting the $settings array of "config-global.php". Could I please get some advice on the best way to append the array within my bootstrap please. Tim Update Here is a cut down version of my bootstap file setup attempting to implement Nikolaos's suggestion. class

Redirecting to 404 route in PhalconPHP results in Blank Page

烈酒焚心 提交于 2019-12-11 09:55:54
问题 I have setup a router, and in it, defined a route for 404s: <?php use Phalcon\Mvc\Router; $router = new Router(FALSE); $router->removeExtraSlashes(true); $route = $router->add('/', ['controller' => 'index', 'action' => 'index']); $route->setName("index"); // other routes defined here... $router->notFound([ "controller" => "index", "action" => "route404" ]); ?> My IndexController: <?php class IndexController extends ControllerBase { public function indexAction() { // code removd for berevity }

How do I create common template with header and footer for phalcon projects with Volt Engine

£可爱£侵袭症+ 提交于 2019-12-11 06:29:18
问题 I want to create a common template with header and footer for every pages in /views using phalcon volt engine my folder hierarchy is below /views /user register.volt /layouts header.volt footer.volt I want to get both code of header.volt and footer.volt into register.volt page this is the code in header.volt <div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container-full"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle=