0

I installed Phalcon PHP as described in https://docs.phalcon.io/3.4/en/webserver-wamp. In this case the URL reads 3.4 because it applies alike for versions 4 and 5.

The WAMP server version is 3.2.6 configured with PHP 8.0.13

Everything was fine so far, so I continued installing the developer tools using composer as described in https://docs.phalcon.io/5.0/en/devtools.

Composer was installed globally and so were the developer tools, but when I type "phalcon" in the command window, the following error is shown:

C:\>phalcon

Fatal error: Uncaught Error: Class "Phalcon\Script" not found in C:\Users\Joachim\AppData\Roaming\Composer\vendor\phalcon\devtools\phalcon.php:38
Stack trace:
#0 {main}
  thrown in C:\Users\Joachim\AppData\Roaming\Composer\vendor\phalcon\devtools\phalcon.php on line 38

C:\>

PSR and Phalcon extensions were successfully installed and I can see them in the WAMP Localhost page. The Path environment variable contains the path to phalcon, composer, wamp, etc, nothing is missing as far as I can see.

Have anyone dealt with this error?

What could be the problem?

apaderno
  • 28,547
  • 16
  • 75
  • 90
jgarcias
  • 337
  • 3
  • 17
  • In case someone asks, I downloaded the following files according to my architecture: `phalcon-php8.0-ts-windows2019-vs16-x64.zip` and `php_psr-1.2.0-8.0-ts-vs16-x64.zip` – jgarcias Jan 05 '22 at 13:59
  • Other PHP web Apps (including Laravel) work fine with my current WAMP server, so all requirements were installed correctly. I tried to install Phalcon dev-tools manually in another directory, downloading a .zip file and configuring the environment variables accordingly. It didn't work either. – jgarcias Jan 05 '22 at 14:06
  • _Small Note_ Non of the WAMPServer folders should ever be set on the PATH. WAMPServer is too flexible to be constrained like that – RiggsFolly Jan 06 '22 at 11:13

2 Answers2

1

I'm a bit late answering this, but in case anyone else stumbles across it via Google the problem is that some namespaces have been altered between Phalcon4 and Phalcon5. I believe Phalcon\Config is one of those classes.

Until the devtools have been updated for Phalcon5, you'll either need to build the scaffolding manually, or copy an old Phalcon 3 or 4 project and update the namespaces.

The perils of using alpha/beta releases, unfortunately.

Gareth
  • 5,693
  • 3
  • 28
  • 37
0

you didn't mention which phalcon version but since you are using php 8 the only version supporting php 8 is phalcon 5

your issue is most likely in your php.ini for the cli since wamp uses different files for apache and cli.

to fix the issue first remove the devtools package you installed globally then edit the cli php.ini in [wampDir]\bin\php\php8.0.13\php.ini and include psr and phalcon and install the devtools again using composer

you can also download the phar file here and test it in the cli

php phalcon.phar
Talal
  • 394
  • 1
  • 13
  • You are right. I installed Phalcon PHP version 5.0.0 Alpha7 and Phalcon DevTools Version: 4.2.0 – jgarcias Jan 12 '22 at 14:12
  • After checking the PHP CLI and Web version in use, I restarted WAMP and I found this error in the PHP error log: – jgarcias Jan 12 '22 at 14:21
  • [12-Jan-2022 14:13:38 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'php_phalcon.dll' (tried: c:/wamp64/bin/php/php8.1.0/ext/php_phalcon.dll (The specified procedure could not be found), c:/wamp64/bin/php/php8.1.0/ext/php_php_phalcon.dll.dll (The specified module could not be found)) in Unknown on line 0 [12-Jan-2022 14:13:38 UTC] PHP Warning: PHP Startup: psr: Unable to initialize module Module compiled with module API=20200930 PHP compiled with module API=20210902 These options need to match in Unknown on line 0 – jgarcias Jan 12 '22 at 14:21
  • Phalcon command is working but the same error is thrown when I try to create a project: `Fatal error: Uncaught Error: Class "Phalcon\Config" not found in C:\web\app\devTools\src\Builder\Component\AbstractComponent.php:48` – jgarcias Jan 12 '22 at 14:22
  • your issue is now is the php's cli version is ```php8.1.0``` change it to ```8.0.13``` by right click on wamp server tray icon then tools then change php cli version – Talal Jan 12 '22 at 23:15
  • I wanted to try both CLI and WEB with PHP 8.1.0, but the result is exactly the same as when I used PHP 8.0.13 for both of them. – jgarcias Jan 13 '22 at 11:17
  • phalcon 5 the extension 5.0.0beta2 (which i used to test this issue) and 5.0.0 Alpha7 is compiled using php 8.0 i'm not sure it will work for php 8.1. when editing php's ini file when it comes to wamp there is two files one for apache ```phpForApache.ini``` and the other one is for cli ```php.ini``` – Talal Jan 13 '22 at 12:57
  • in your command prompt run ```php -v``` and make sure its ```8.0.13``` and then run ```php -m``` and make sure ```phalcon``` and ```psr``` is there . after that download the phar file [here](https://github.com/phalcon/phalcon-devtools/releases) and test it by running ```php phalcon.phar``` – Talal Jan 13 '22 at 13:00
  • `php -m` revealed the extensions are loaded. The test of `php phalcon.phar` returned the expected results. I double checked that CLI and Web php versions are 8.0.13. All looks correct so far, but when I try to create a new project: `Class "Phalcon\Config" not found in C:\web\phalcon-tools\src\Builder\Component\AbstractComponent.php:48` – jgarcias Jan 13 '22 at 14:36
  • if you used the composer package you might need to remove it and install it again. i tried to install the devtools when the extension wasn't loaded and i got version ^2.0 – Talal Jan 13 '22 at 17:53
  • Yes, I already tried the composer package and removed it later. Then, I downloaded the .zip archive and that was my latest move, but I still get those errors (class not found) all the time. – jgarcias Jan 14 '22 at 02:08
  • if ```php phalcon.phar``` is working as expected then your issue is with composer. it may uses another version of php especially if you installed it using windows installer. if this didn't solve your issue you can create a batch file ```php phalcon.phar``` and name it ```phalcon.bat``` and put it in one of your PATHs – Talal Jan 14 '22 at 02:45
  • I just created another .bat file with php phalcon.phar inside, but it still throws the same error (class "phalcon/config" not found). I am done with this. – jgarcias Jan 14 '22 at 11:49