phalcon

Phalcon auto pagination with jquery

╄→гoц情女王★ 提交于 2019-12-08 07:17:00
问题 I want implement pagination like facebook pagination. In my blog i want it will load first 3post and then when page scroll to bottom it will load more ... i want simple jquery without any plugins. thats why i try to follow this link: example and example2 but not figure it how to use phalcon pagination jquery workable. my currnet configure is like: [controller] $bloger = Blogs::find(["order" => "datetime DESC"]); $numberPage = $this->request->getQuery('page', 'int', 1); /** @var \Phalcon

Volt not including file if path is concatenated

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

phalcon php built-in server Failed opening required .htrouter

穿精又带淫゛_ 提交于 2019-12-07 13:00:53
问题 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

Loading Models with INNER JOIN

限于喜欢 提交于 2019-12-07 08:42:26
问题 Let's say I have a Phalcon\Mvc\Model that I load using ::findFirst($id) . How can I swap in a custom query that would load the model row and do INNER JOIN on some other table? Thanks! 回答1: I'm sure you can use the Query builder for simple joins like: <?php //Getting a whole set $robots = $this->modelsManager->createBuilder() ->from('Robots') ->join('RobotsParts') ->orderBy('Robots.name') ->getQuery() ->execute(); //Getting the first row $robots = $this->modelsManager->createBuilder() ->from(

依赖注册的简单接触

别来无恙 提交于 2019-12-06 20:56:21
##1.在组件内部创建依赖对象 首先,我们假设,我们要开发一个组件命名为SomeComponent。 这个组件中依赖一个数据库连接。 组件 依赖 数据库连接对象,我们在组件中创建数据库连接对象 ###demo1: class SomeComponent { /** * The instantiation of the connection is hardcoded inside * the component so is difficult to replace it externally * or change its behavior */ public function someDbTask() { $connection = new Connection(array( "host" => "localhost", "username" => "root", "password" => "secret", "dbname" => "invo" )); // ... } } $some = new SomeComponent(); $some->someDbTask(); 在这个例子中,数据库连接在component中被创建,这种方法是不切实际的,这样做的话,我们将不能改变数据库连接参数及数据库类型等一些参数。而且耦合性太高了。 #2.改进: 把依赖对象注入组件中

PhalconPHP Database transactions fail on server

ぃ、小莉子 提交于 2019-12-06 20:26:15
问题 I have developed a website using PhalconPHP. the website works perfectly fine on my local computer with the following specifications: PHP Version 7.0.22 Apache/2.4.18 PhalconPHP 3.3.1 and also on my previous Server (with DirectAdmin): PHP Version 5.6.26 Apache 2 PhalconPHP 3.0.1 But recently I have migrated to a new VPS. with cPanel: CENTOS 7.4 vmware [server] cPanel v68.0.30 PHP Version 5.6.34 (multiple versions available, this one selected by myself) PhalconPHP 3.2.2 On the new VPS my

Displaying a server side rendered reactJS component within a PHP application

喜欢而已 提交于 2019-12-06 16:40:13
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 achieve this my research implies that I should be using React's React.renderComponentToString Having

Phalcon very slow using Phalcon\\Http\\Response();

☆樱花仙子☆ 提交于 2019-12-06 16:08:06
I am experiencing a very strange issue with Phalcon. Whenever I use Response inside a controller the framework becomes very slow. Here is my simple controller: <?php // file: app/controllers/TestController.php use Phalcon\Mvc\View; class TestController extends ControllerBase { private $response; public function initialize() { $this->view->setRenderLevel(View::LEVEL_NO_RENDER); $this->response = new Phalcon\Http\Response(); $this->response->setStatusCode(200, "OK"); } public function indexAction() { $this->response->setContent("phalcon")->send(); // very slow } } Whenever I use new Phalcon\Http

Phalcon PHP: Modify a request URL before it gets dispatched

倾然丶 夕夏残阳落幕 提交于 2019-12-06 15:50:31
I'm looking for a way to modify a request URL before it gets dispatched. For instance, the following URLs should be handled by the same controller/action: /en/paris /de/paris /paris I would like to capture the country code if it is present, then rewrite the URL without it so that controllers don't have to deal with it. I tried the 'dispatch:beforeDispatchLoop' event but it doesn't seam to be designed for that. Any idea? If you can convention that all country code comes first in the path, perhaps an additional rewrite rule can help you: <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !

How to validate Google reCaptcha v2 using phalcon/volt forms?

蓝咒 提交于 2019-12-06 14:18:03
问题 How do you validate the new Google reCaptcha using volt and phalcon techniques? (Just wanted to share what I did to make it work, see answer below, hope it helps...) 回答1: What you will need A Validator (RecaptchaValidator in this case) Form implementation Controller implementation (actually no changes needed here, but for completeness...) View implementation (optional) Config entries for your recaptcha keys and url (nicer/cleaner this way) (optional) A recaptcha element for automatic