2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Phalcon HelloWorld

2
Last updated at Posted at 2019-03-27

概要

MacでPHPv7.2のインストール 〜 curl localhostで適当プロジェクトにアクセスするまで

ver

  • Phalcon v3.4.2
  • PHP v7.2

Install PHP

brew upgrade php
brew install php@7.2 # Phalconがphp7.2にしか対応してない? 7.3だと、phalcon.soのloadに失敗するとでる `Symbol not found: __zval_ptr_dtor`
brew link --force php@7.2 # 必要なら
brew services start php # php-fpmが開始される
php -v # 7.2が表示されるはず

Install composer

brew install composer

Phalcon インストールする必要があるもの

  • phalcon.so
  • phalcon用のPHP Extension。Phalcon本体はCで動いている
  • phalcon-devtools
  • phalcon コマンドのために必要

Install phalcon.so

brew tap tigerstrikemedia/homebrew-phalconphp
brew install php72-phalcon
ls /usr/local/Cellar/php72-phalcon/3.4.2/phalcon.so # 存在するはず
echo "extension=phalcon.so" > /usr/local/etc/php/7.3/conf.d/phalcon.ini
brew services restart php

Install phalcon-devtools

今回はcomposer経由でインストールする

mkdir ~/phalcon
cd ~/phalcon
vim composer.json # 中身は下記
composer install
ls ~/phalcon/vendor/phalcon/devtools/phalcon.php # 存在確認
echo "alias phalcon=~/phalcon/vendor/phalcon/devtools/phalcon.php" >> ~/.zshrc # zshを使っているという前提で・・
source ~/.zshrc
phalcon # 疎通テスト
composer.json
{
    "require": {
        "phalcon/devtools": "dev-master"
    }
}

Phalconでプロジェクト作成

mkdir /tmp/test # 適当にディレクトリ作成
cd /tmp/test
phalcon project mypj

nginxの設定

vim /usr/local/nginx/conf/nginx.conf # 中身は下記
nginx -s reload
nginx.conf
...略

    server {
        listen       10000;
        server_name  localhost;

        location ~ \.php$ {
            root   /tmp/test/mypj/public;

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass localhost:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }

(...実際すごい適当)

アクセステスト

curl localhost:10000/index.php
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?