LoginSignup
1
2

More than 3 years have passed since last update.

Phalcon Devtoolsのインストール(mac)

Last updated at Posted at 2020-09-09

前回、vagrantでPhalcon開発環境を作ったが、Phalcon Devtoolsの使用も必要となり、
ドキュメントと多少違うところがあり、エラー解決の過程をメモとしておく。

composer global require phalcon/devtools

で、次にエラーが出てきた:

 Problem 1
    - phalcon/devtools v4.0.3 requires ext-phalcon ^4.0.0 -> the requested PHP extension phalcon is missing from your system.
    - phalcon/devtools v4.0.2 requires ext-phalcon ^4.0.0 -> the requested PHP extension phalcon is missing from your system.
    - phalcon/devtools v4.0.1 requires ext-phalcon ^4.0.0 -> the requested PHP extension phalcon is missing from your system.
    - phalcon/devtools v4.0.0 requires ext-phalcon ^4.0.0 -> the requested PHP extension phalcon is missing from your system.
    - Installation request for phalcon/devtools ^4.0 -> satisfiable by phalcon/devtools[v4.0.0, v4.0.1, v4.0.2, v4.0.3].

  To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/etc/php/7.3/php.ini
    - /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

「the requested PHP extension phalcon is missing 」に注意。phalcon自体をmacに入れておく。

brew install phalcon/extension/phalcon@4.0.0

composerを今度実行したら、また次にエラーが出た:

  Problem 1
    - laravel/installer v3.0.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - laravel/installer v3.0.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - laravel/installer v3.0.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - Installation request for laravel/installer (locked at v3.0.1, required as ^3.0) -> satisfiable by laravel/installer[v3.0.1].

解決:

$ brew install php@7.4

次にエラーが出てきたら、/usr/local/sbinを作り、権限を与える。

Warning: php 7.4.10 is already installed, it's just not linked
You can use `brew link php` to link this version.
(base) baobaochudeiMac:~ baobaochu$ brew link php
Linking /usr/local/Cellar/php/7.4.10...
Error: Could not symlink sbin/php-fpm
/usr/local/sbin is not writable.
$ sudo mkdir /usr/local/sbin
$ sudo chmod -R 777 /usr/local/sbin
$ brew link php@7.4

最後にもう一回インストールし、問題なさそうだ。

$ composer global require phalcon/devtools

インストールしたが、また使えないようだ。

$ phalcon
-bash: phalcon: command not found

ドキュメントに注意:https://github.com/phalcon/phalcon-devtools
If you get a "phalcon: command not found" message while creating the symlink, make an alias.

$ alias phalcon=/home/[USERNAME]/phalcon-devtools/phalcon

composer経由でインストールした場合、同じく/phalcon-devtools/phalconの場所を探せ。

筆者の場合は下記のパースを入れ替えて、symlinkを作る:

$ cd $HOME

$ vim ~/.bashrc
#開いたファイルに次の一行を追加
alias phalcon=/Users/[USERNAME]/.composer/vendor/phalcon/devtools/phalcon

$ vim .bash_profile
#開いたファイルに次の一行を追加
source ~/.bashrc

#最後に、下記のコマンドを実行
$ source ~/.bash_profile

今度は無事に使えるようになった。

$ phalcon

Phalcon DevTools (4.0.3)

Available commands:
  info             (alias of: i)
  commands         (alias of: list, enumerate)
  controller       (alias of: create-controller)
  module           (alias of: create-module)
  model            (alias of: create-model)
  all-models       (alias of: create-all-models)
  project          (alias of: create-project)
  scaffold         (alias of: create-scaffold)
  migration        (alias of: create-migration)
  webtools         (alias of: create-webtools)
  serve            (alias of: server)
  console          (alias of: shell, psysh)

前回、仮想環境を作ったが、ツールを使用してプロジェクトを作成しテストする。
まず以前作成したindexファイルを削除して、次に

$ cd phalcon
$ phalcon create-project store
$ varant ssh
$ sudo vi /etc/nginx/nginx.conf

nginxのドキュメントルートを/var/www/store/publicに変更します。

/etc/nginx/nginx.conf
#/var/www/
root         /var/www/store/public;

サーバー再起動して、次のページは出てきたら、構築終了。

$ sudo systemctl restart nginx

スクリーンショット 2020-09-09 17.23.45.png

補足:phpstormをご使用の場合、Phalcon 4 Autocompleteをインストールすることでコードは自動補完できる。
https://plugins.jetbrains.com/plugin/12776-phalcon-4-autocomplete

1
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
1
2