lang/php

PHP Phalcon Installation

C/H 2018. 6. 4. 13:04

Require

  • PHP >= 5.5
  • curl
  • gettext
  • gd2 (to use the Phalcon\Image\Adapter\Gd class)
  • libpcre3-dev (Debian/Ubuntu), pcre-devel (CentOS), pcre (macOS)
  • json
  • mbstring
  • pdo_*
  • fileinfo
  • openssl

Optional Depending

  • PDO Extension as well as the relevant RDBMS specific extension (i.e. MySQL, PostgreSql etc.)
  • OpenSSL Extension
  • Mbstring Extension
  • Memcache, Memcached or other relevant cache adapters depending on your usage of cache

Phalcon Installation

Phalcon Installation : Linux, Mac, Windows 및 Compile 설치 제공

# packagecloud.io Debian
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash
sudo apt-get update
sudo apt-get install php7.0-phalcon

# ppa:ondrej/php Debian
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php-phalcon

Developer Tools Installation

cd ~/
git clone git://github.com/phalcon/phalcon-devtools.git
cd phalcon-devtools/
. ./phalcon.sh
ln -s ~/phalcon-devtools/phalcon.php /usr/bin/phalcon
chmod ugo+x /usr/bin/phalcon

phalcon commands
# 명령어가 표시된다.

phalcon create-project store
# store 폴더 아래 프로젝트가 생성된다.

php -S 127.0.0.1:1337
open http://127.0.0.1:1337/public/
# Congratulations! 페이지가 나오면 성공


# Hello Controller 작성, http://localhost/hello
cd store
phalcon create-controller --name=hello
vi app/controllers/HelloController.php
sudo vi /etc/hosts
sudo vi /etc/apache2/sites-available/phalcon.conf
sudo ln -s /etc/apache2/sites-available/phalcon.conf /etc/apache2/sites-enabled/phalcon.conf
sudo systemctl reload apache2
<?php
class HelloController extends \Phalcon\Mvc\Controller
{
    public function indexAction()
    {
        echo "Hello World";
    }
}
127.0.0.1 phalcon.com
<VirtualHost *:80>
        ServerName phalcon.com
        DocumentRoot /home/username/phalcon/store
    
        ErrorLog ${APACHE_LOG_DIR}/phalcon.error.log
        CustomLog ${APACHE_LOG_DIR}/phalcon.access.log combined
    
        <Directory /home/username/phalcon/store>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
                <IfModule mod_rewrite.c>
                  RewriteEngine On
                    RewriteBase /
                    RewriteCond %{REQUEST_FILENAME} !-f 
                    RewriteCond %{REQUEST_FILENAME} !-d 
                    RewriteRule ^(.*)$ index.php?/$1 [L] 
                </IfModule>
            </Directory>
        #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>

* http://phalcon.com/, http://phalcon.com/hello 브라우저에서 "Hello World" 가 표시되면 성공

반응형