Install Phalcon Devtools (mac)

Sep 9, 2020 PHP Phalcon

Last time, I created a Phalcon development environment with vagrant, but I also needed to use Phalcon Devtools, so

There are some differences from the document, so make a note of the error resolution process.

composer global require phalcon / devtools

Then I got an error:

 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.

Note “the requested PHP extension phalcon is missing”. Put phalcon itself in mac.

brew install phalcon / extension / [email protected]

The next time I run composer, I get another error:

  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].

Solution:

$ brew install [email protected]

The next time you get an error, create / usr / local / sbin and give it permission.

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 [email protected]

Finally, install it again and it looks fine.

$ composer global require phalcon / devtools

I installed it, but it doesn’t seem to work again.

$ phalcon
- bash: phalcon: command not found

Note the documentation: 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

If you installed via composer, also find the location of / phalcon-devtools / phalcon.

In my case, replace the following perspectives to create a symlink:

$ cd $ HOME

$ vim ~ / .bashrc
#Add the following line to the opened file
alias phalcon = / Users / [USERNAME] /. composer / vendor / phalcon / devtools / phalcon

$ vim .bash_profile
#Add the following line to the opened file
source ~ / .bashrc

#Finally, execute the following command
$ source ~ / .bash_profile

Now I can use it safely.

$ phalcon

Phalcon DevTools (4.0.3)

Available commands: 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)

Last time, I created a virtual environment, but I use tools to create and test a project. First delete the previously created index file, then

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

Change the document root of nginx to / var / www / store / public.

# / var / www /
root / var / www / store / public;

After restarting the server and the next page appears, the construction is complete.

$ sudo systemctl restart nginx

Screenshot 2020-09-09 17.23.45.png

Note: If you are using phpstorm, you can auto-complete your code by installing Phalcon 4 Autocomplete. https://plugins.jetbrains.com/plugin/12776-phalcon-4-autocomplete