Reputation: 73
The php function yaml_emit_file()
is not working. I have installed and included the php_yaml.dll
in my php.ini
file restarted the server but still when I use this function, I get this error (when I run composer):
Call to undefined function RS\composer\yaml_emit_file()
Okay so a little about the background:
PHP version 7.1.7 & Composer version 1.5.1
I am using this function in a ScriptHandler.php file which is invoked when Composer
is run. In this script I have a function buildModuleList
which is called on post-update-cmd
event of Composer
. Everything else in the code is working fine.
I am in doubt that maybe I am using this function in wrong context or something like that.
Here is the code snippet where I am using yaml_emit_file()
(Providing this just for reference, tell me if am using it the wrong way!):
if (!$fs->exists($moduleListFile)) {
$fs->touch($root.'/profiles/thunder/modulelist.yml');
$fs->chmod($root . '/profiles/thunder/modulelist.yml', 0666);
if(!empty($moduleList)){
$createyml= yaml_emit_file($moduleListFile, $moduleList);
if (!$createyml){
$io->writeError('<error>Cannot create modulelist.yml</error>');
}
}
$io->write('Success: Created new modulelist.yml', $newline= TRUE);
}
else{
$fs->file_put_contents($moduleListFile, $installedPackage, FILE_APPEND);
$io->write('Success: Module entry in modulelist.yml', $newline= TRUE);
}
Upvotes: 1
Views: 2027
Reputation: 3
Since this happened to me on PHP 8.4.4, the reason for me is that the PHP interpreter is trying to find the yaml_*
function in the current namespace, so I called it with a backslash in front of the function.
\yaml_emit($payload);
Given the context, I assume that you are in the `RS\composer' namespace.
Upvotes: 0
Reputation: 845
i hope this help someone i test it on Windows 10 XAMPP v3.2.4 PHP 8.0.2
Download the latest YAML DLL Package from : https://pecl.php.net/package/yaml Unzip the files
Move the php_yaml.dll file to xampp/php/ext folder Open your php.ini in xampp/php add a new line extension=php_yaml.dll, save and exit Restart your XAMPP Servers make a PHP file put into
<?php
phpinfo();
?>
Search the string yaml on the page. If it says Enabled then your YAML Extension is working.
Upvotes: 0