phalcon

Sending variable from volt to custom function

余生长醉 提交于 2019-12-11 03:24:42
问题 I have created a custom function I can access from the volt. The function seems to work fine, but I cannot manage to send the variable to the function. It sends the variable as text instead of its value. The twig function: $volt->getCompiler()->addFunction('getusergroup', function ($user) { return \Models\User::getUserGroup($user); }); The function in the Model: public static function getUserGroup($user) { return UserGroup::find(array('conditions' => 'user_id = ' . $user)); } The lines in

How to copy the CSS and JS files in vendor folder of composer to public?

谁说胖子不能爱 提交于 2019-12-10 12:32:53
问题 I'm just starting to learn several PHP frameworks. The examples I tried all use composer , which I have not used before, so things are not exactly clear to me yet. I specified some JS and CSS libraries in composer.json and ran composer install . Now these libraries are added to the vendor folder. Now how am I supposed to use the JS and CSS files that are in those folders, for example bootstrap/dist/css/bootstrap.min.css ? The examples I tried either just have a copy in the public/css folder

Phalcon backup view path

南楼画角 提交于 2019-12-10 11:34:52
问题 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

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

时光怂恿深爱的人放手 提交于 2019-12-10 11:18:47
问题 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

How to retrieve similar tags data from db in phalcon?

一个人想着一个人 提交于 2019-12-10 00:25:43
问题 I'm New in Phalcon. I decided to look at Phalcon php as an alternate php framework to Codeigniter. I'm Implementing a blog with tags. where first of im inserting tags value into a single column into the db. I follow tags plugin example from: https://github.com/mfiels/tagsly/blob/master/index.html its inserted multiple value into a single column like "php,jquery,asp,html,css". Now i just retrive the value from db to volt like this way: [controller] $bloger = $this->modelsManager->executeQuery(

How can I dynamically reference template file in volt template?

心不动则不痛 提交于 2019-12-09 20:57:33
问题 We know, {% include header.volt %} is reference file with name's header.volt . How can I dynamically reference template file in volt template? like this: {% include variable %} when variable equal footer.volt , theen the program will reference file with name's footer.volt when variable equal index.volt , then the program will reference file with name's index.volt ... thanks! 回答1: I'm not sure if using variables in include will work, but you can always use partial() to include your template: {

When should we use multi-module structure (instead simple structure) in php Phalcon

﹥>﹥吖頭↗ 提交于 2019-12-09 13:38:03
问题 When should we use multi-module structure (instead simple structure) in php Phalcon? I have found some multi-module skeleton, such as: https://github.com/ovr/phalcon-module-skeleton, https://github.com/phalcon/mvc/tree/master/multiple. But I don't know should i use this multi-module structure in a project instead use multi projects. Something i can think about it is: more complex configuration, complex folder structure, my web url be longer (/[module]/[controller]/[action]) and , importantly,

Netbeans syntax highlighting for volt (twig) and php in phtml files

痞子三分冷 提交于 2019-12-09 13:17:17
问题 I'm working with Phalcon in Netbeans. I see I can use twig plugin for template highlighting for volt files. I am using phtml files and want highlighting for volt (twig) and php. Is this possible? Also related - Netbeans keeps duplicating my phtml view files and adding the extention .phtml.php to them. How can I fix that? 回答1: Go to Tools->Options->Miscellaneous->Files right to "File Extensions" press "create" and type there "volt". After that in "Associated File Type (MIME)" choose "TWIG

Cross controller variables in Phalcon

余生颓废 提交于 2019-12-09 03:14:47
问题 In an effort to keep my code DRY I would like to be able to define "cross controller" variables. Classic example is that I would like access to some config items that are loaded in my bootstap. What is the best practise method of achieving this? Tim 回答1: You can always use the Di container. Once you register a component in the Di it is available in the controller by the magic method. For instance: // Bootstrap $configFile = ROOT_PATH . '/app/config/config.ini'; // Create the new object

Displaying a server side rendered reactJS component within a PHP application

半世苍凉 提交于 2019-12-08 08:45:23
问题 I have previously used reactJS on another project. When building said project i noticed a downfall namely the loss of SEO benefit associated with JS rendered components. I am rebuilding an old project and I would like to replace some of the Javascript with ReactJS. For example, a multi step form - I'd like to replace it with a stateful component that displays the correct stage as required. I would however like to maintain the SEO aspects of the page by having the first step spiderable. To