0

I'm trying to start with Zephir on Windows 10 OS, PHP Version 7.3.0.

I've to figure out the installation guide. I guess, I don't need GCC according to Download and Install GCC Compiler in C for Windows PC, because Visual C++ 2005 compiler is already installed.

I've downloaded and installed Setup re2c-0.9.4.exe Re2C for Windows instead Re2C.

In C:\xampp\htdocs\user\test I have test.php:

 <?PHP 
 require 'calc.zep';
 $m = new MyClass();
 $m->hello();
 ?>

Also, I've added Zephir Syntax Highlight package to Sublime Text 3 IDE and created second document calc.zep with:

class MyClass
{
    public function hello()
    {
        echo "hello!";
    }
}

Then install Zephir parser, locating php_zephir_parser.dll version zephir_parser-php-7.3-nts-windows2019-vc15-x64.zip to C:\xampp\php\ext. Next, I've edited C:\xampp\php\php.ini file by adding these lines:

[Zephir Parser]
extension=php_zephir_parser.dll

to Dynamic Extensions, but with [Zephir Parser] part of lines, xampp does not load localhost. So I've added it like this ;extension=php_zephir_parser at the end of the extensions list, hope this is the correct way of edit for php.ini with extension adding:

    ...
    ;extension=pdo_sqlite
    ;extension=pgsql
    ;extension=shmop 
    ;extension=php_zephir_parser

According to install Zephir Git Way:

git clone https://github.com/zephir-lang/zephir to C:\xampp\htdocs\user\test, then cd zephir to C:\xampp\htdocs\user\test\zephir and ./install -c which is

not recognized as an internal or external command, operable program or batch file.

then composer install, and with zephir help or zephir generate I get this error:

Parse error: syntax error, unexpected 'Config' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in C:\xampp\htdocs\user\test\zephir\Library\Logger\Formatter\CompilerFormatter.php on line 33

composer -V shows Composer version 2.3.9

test.php result is the same as without php_zephir_parser.dll:

class MyClass { public function hello() { echo "hello!"; } } Fatal error: Uncaught Error: Class 'MyClass' not found in C:\xampp\htdocs\user\test\test.php:5 Stack trace: #0 {main} thrown in C:\xampp\htdocs\user\test\test.php on line 5

Maybe I have to update PHP Version 7.3.0. to PHP Version 7.4.0.

Do I have to follow another guide Zephir Installation/Usage Guide (Windows) or PHP: A case for Zephir or I've missed or done something incorrectly with guidelines for installing the Zephir environment on Windows OS.

Any guide, advice, or example would be useful.

edit:

I've downloaded php-8.1.12-Win32-vs16-x64 and added php-8.1.12 folder to C:\xampp directory with keeping previous PHP Version 7.3.0 folder there.

In php-8.1.12 folder I've created php.ini from the copy of php.ini-development and uncommented extension_dir = "ext", extension=curl, extension=ftp, extension=fileinfo, extension=openssl, extension=pdo_mysql and extension=pdo_sqlite.

In C:\xampp\apache\conf\extra\httpd-xampp-config file I've added PHP 8.1.12 Set-up ScriptAlias /php-8.1.12/ "C:/xampp/php-8.1.12/" and <Directory "C:/xampp/htdocs/user/test">, according this example httpd-xampp.conf

<Directory "C:/xampp/htdocs/user/test"> shows PHP Version 8.1.12 with phpinfo(); and CLI php --version inside test folder and keeps older PHP versions separately for other projects.

The result with zephir help command is successful: Zephir 0.16.3 is installed, but zephir generate requires a parser:

[ERROR] The Zephir Parser extension is not loaded. Note: Zephir no longer distributed with internal parser. To install latest stable Zephir Parser please refer to: https://github.com/zephir-lang/php-zephir-parser

Then I've added zephir_parser-php-8.1-nts-windows2019-vs16-x64.zip php_zephir_parser.dll to C:\xampp\php-8.1.12\ext, then added ;extension=php_zephir_parser.dll to C:\xampp\php-8.1.12\php.ini.

If I uncomment with removing semicolons ; from extension=php_zephir_parser.dll I get the error:

Server error! The server encountered an internal error and was unable to complete your request. Error message: malformed header from script 'php-cgi.exe': Bad header:
Error 500 localhost Apache/2.4.37 (Win32) OpenSSL/1.1.1a PHP/7.3.0

With the restart of localhost I've changed extension=php_zephir_parser to extension=zephir_parser and also have tried extension=php_zephir_parser.dll, in all cases zephir build command:

C:\xampp\htdocs\user\test\zephir PHP Warning: PHP Startup: Unable to load dynamic library 'zephir_parser' (tried: ext\zephir_parser (The specified module could not be found), ext\php_zephir_parser.dll (The specified module could not be found)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'zephir_parser' (tried: ext\zephir_parser (The specified module could not be found), ext\php_zephir_parser.dll (The specified module could not be found)) in Unknown on line 0

[ERROR] The Zephir Parser extension is not loaded. Note: Zephir no longer distributed with internal parser. To install latest stable Zephir Parser please refer to: https://github.com/zephir-lang/php-zephir-parser The system cannot find the path specified. Preparing for PHP compilation... The system cannot find the path specified. [ERROR] file_get_contents(ext\configure.js): Failed to open stream: No such file or directory

and php --ini from C:\Users\User>:

PHP Warning: PHP Startup: Unable to load dynamic library 'zephir_parser' (tried: ext\zephir_parser (The specified module could not be found), ext\php_zephir_parser.dll (The specified module could not be found)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'zephir_parser' (tried: ext\zephir_parser (The specified module could not be found), ext\php_zephir_parser.dll (The specified module could not be found)) in Unknown on line 0

Configuration File (php.ini) Path: Loaded Configuration File:
C:\xampp\php-8.1.12\php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none)

The answer on error zephir_parser extension not loaded windows says that's the using of extension via a web server, requires adding extension=zephir_parser to both the CLI and the apache/fpm php.ini files, but I can't find this directory in C:\xampp\apache.

According Zephir Installation/Usage Guide (Windows) I've downloaded php-debug-pack-8.1.12-Win32-vs16-x64.zip and deps-7.1-vc14-x64.7z. But then I installed it according to Get Started with PHP SDK with composer require contentstack/contentstack command to C:\xampp\htdocs\user\test

emss
  • 65
  • 9
  • You seem to have jumped around between lots of different guides. Sometimes there's more than one way to do something, but that doesn't mean you can start with method 1, then switch to method 2 half-way through. Pick one, and stick to it, trying to figure out specific steps you get stuck on. – IMSoP Nov 10 '22 at 18:00
  • One thing you've definitely done, though, is downloaded the wrong DLL: the "php-8.1" refers to the version of PHP it will work with, but you say you're using PHP 7.3. (The fact that you're using [a PHP version which reached end of life last year](https://www.php.net/eol.php) may not be helping, if the guides you're following were written more recently.) – IMSoP Nov 10 '22 at 18:02
  • @IMSoP Hello, I've edited the question with all steps and points where I've stuck, which possibly is adding an extension to php.ini and ./install -c command not recognized. And Parse error with zephir help. I've changed the version with PHP 7.3 to zephir_parser-php-7.3-nts-windows2019-vc15-x64.zip – emss Nov 10 '22 at 20:30

0 Answers0