phalcon

Phalcon环境搭建与项目开发

懵懂的女人 提交于 2019-12-04 11:11:49
简介 Phalcon 是开源、全功能栈、使用 C 扩展编写、针对高性能优化的 PHP 5 框架。 开发者不需要学习和使用 C 语言的功能, 因为所有的功能都以 PHP 类的方式暴露出来,可以直接使用。 Phalcon 也是松耦合的,可以根据项目的需要任意使用其他对象。 官网: https://phalconphp.com/ 源码: https://github.com/phalcon/cphalcon/ 编译与安装 我这里使用的是docker来搭建运行环境,Dockerfile文件如下: FROM daocloud.io/library/php:7.0.10-fpm MAINTAINER Minho <longfei6671@163.com> RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng12-dev \ libpcre3-dev \ gcc \ make \ bzip2 \ libbz2-dev \ libmemcached-dev \ git \ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-install mbstring \ && docker-php

How do I use phalcon-devtools\ide\phpstorm in phpstorm?

不羁岁月 提交于 2019-12-04 07:48:45
问题 I am trying to integrate the Phalcon developer tools with phpstorm. There is a video here, but I am unable to view it due to my location. I can't find any other usable reference in the documentation, how can I accomplish this? 回答1: Here are the steps. Make sure you have the phalcon-devtools installed Instructions Create a project using phalcon-devtools (unless you already have a project) Launch PHPStorm and create the project there (unless you already did that). Click File-Settings (Ctrl+Alt

Phalcon PhP - how to change the view dynamically

烈酒焚心 提交于 2019-12-04 02:00:34
问题 I'm working in a website where part of it I have the static html, so I created a layout and in it I'm inserting the static content using views. My problem is as this website has many pages I feel wrong creating an action for each url. So I implemented the controller below: class PageController extends ControllerBase { public function initialize(){ $this->init(); $this->view->setLayout( 'website' ); } public function indexAction ($url=''){ if($url == 'about') $this->view->pick('page/about'); }

在Centos/Linux系统下使用Phalcon开发PHP项目

别等时光非礼了梦想. 提交于 2019-12-04 01:59:30
1.Phalcon安装 最好采取源码编译安装。这样可以体验最新的稳定版本。安装过程比较简单,下载tar.gz源码后,解压编译将 phalcon.so 加到php.ini中即可。重启php-fpm,查看phpinfo.php。能够找到下图的结果,则证明安装成功。 2.Phalcon-DevTools安装 为了便于快速创建项目、控制器之类的操作,Phalcon团队开发了DevTools方便开发者使用。你可以访问 https://github.com/phalcon/phalcon-devtools/releases 得到对应版本的DevTools工具。每个版本都有对应的DevTools,千万别弄错了。下载后 unzip 解压,在 /usr/bin 下做一个软链接。今后就可以使用 phalcon 命令了。 ln -s ~/phalcon-devtools/phalcon.php /usr/bin/phalcon chmod ugo+x /usr/bin/phalcon 3.创建项目 在命令行键入 phalcon project hello_world 创建一个简单项目,目录结果如下: 目录结构 ├─.phalcon ├─app │ ├─cache │ ├─config │ ├─controllers │ ├─models │ └─views │ ├─index │ └─layouts └

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

对着背影说爱祢 提交于 2019-12-03 21:20:22
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, performance will be low (for more loading things than). However, I think that there are something

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

风格不统一 提交于 2019-12-03 16:07:02
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? 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 (text/x-twig)". Restart IDE. I use twig syntax in PHPStorm and everything works fine. Look at Netbeans settings

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

自作多情 提交于 2019-12-03 12:45:28
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) 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 class which has a translate method as such: public static function translate() { $return = ''; if (isset(self

Phalcon PHP: Modify a request URL before it gets dispatched

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: 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? 回答1: If you can convention that all country code comes first in the path, perhaps an additional rewrite rule

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

匿名 (未验证) 提交于 2019-12-03 09:18:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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")-

getting exception : Service &#039;db&#039; wasn&#039;t found in the dependency injection container in Phalcon

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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