Working with yaml - php

Me and a friend of mine are working with a project. She was responsible for a part of it, while I would add some functionalities to her code. So she send me her code and I should make it work in my machine and add my part.
However, I'm facing this problem. She has used yaml in the project (which I had no idea it existed before, I don't do web programming, only algorithm implementation). I tried to follow her instructions but got stuck at
Fatal error: Call to undefined function yaml_parse_file() in /var/www/html/cdn/map_of_site.php on line 8
So I thought that I should install the yaml library (which I think I did correctly).
I also added the yaml parser in the php.ini
But the error continues to appear.
The worst part is that I won't be able to get in touch with her for a couple of days (and I kind of dislike telling her that I don't know how to make her code work).
Could you please tell me in general what is required to make a project that uses yaml_parse_file() function work? Like what should I install or where to install it ...
PS: I work with linux mint and the project is php

Your frend used a php module that you don't have installed or enabled.
You can try to install it in the regular way (I don't know linux mint myself):
- apt-get install php5-yaml
- yum install php5-yaml
Or something like that.
If yaml is not available like that, you can try to use pecl.
You need this package: http://pecl.php.net/package/yaml
If you have pecl installed on your system (apt-get install pecl), you can just do pecl install yaml.
Usually when the extension is installed it is also directly enabled. You can test if it is enabled by creating a php file with <?php phpinfo(); ?> in it and running or visiting it (then search for yaml).

It turned out I hadn't installed yaml correctly. This article and the instructions that linux itself gives (<3) helped me solve it:
https://code.google.com/p/php-yaml/wiki/InstallingWithPecl

Related

Trying to get icu4c version 64 working with PHP 5.6 on Mac Catalina

I just got handed a big project running Symfony 3.4, and PHP 5.6, that I'm trying to get working on my "new" Mac Catalina (just purchased and installed, not upgraded from a previous macOS version), and I've gotten things working up to a certain point:
our-symfony-3-project $ bin/console server:start
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
Referenced from: /usr/local/opt/php#5.6/bin/php
Reason: image not found
zsh: abort bin/console server:start
I was able to fix a previous similar error with needing openssl 1.0.0 (I had to compile it from source using Homebrew then link it), and I think the solution is the same here, but it appears that I need to find the library or repo or download for icu4c version 64 (not sure I'm reading this right) to get brew extract to install it (it won't any other way), or figure out how to compile it and manually get it working for PHP 5.6, and I'm not finding the library I need apparently.
I've gone through pages and pages and probably a hundred command attempts trying to fix this error... and so far the recommendations have either been outdated (due to macOS/brew changes), or just didn't work.
I'd like to know where I can find the appropriate file/download/repo to just be able to install or compile this through brew or otherwise. PS: I know we shouldn't be using old versions but I just got this job and the company will not upgrade for a while.
I'm answering this by saying that I got the repo to work on a PHP 5.6 host using MAMP Pro (and Apache, not that that's relevant)... which already had the required libraries in question.
I went through the docs on the trial version (version 6.3.2):
https://documentation.mamp.info/en/MAMP-PRO-Mac/Settings/Hosts/General/
However, unlike Homebrew, switching PHP versions across hosts in MAMP Pro doesn't overwrite PHP symlinks like brew unlink and brew link does, I have to still edit my .zshrc file aliases and my PATH to have things like php (or pecl or pear etc) point to the MAMP Pro PHP version folders to get them to work correctly with the repos, as well as with composer (which runs the php command). Even MAMP's documentation says to modify the files yourself...
I can't tell yet if this difficulty is just natural to having multiple hosts with different PHP versions configured, as I could see how multiple variations running at the same time could conflict if they're using the same system files (like /usr/local files)... which sound like system software dependencies, and I don't know that these dependencies could be relegated to their own host folders (like /Applications/MAMP/bin/php/php5.6.40 folders), or maybe I just missed something somewhere. I'll update this answer if I learn better what to do here, or will add another answer if I find a way to do them using Homebrew better.

How to enable SSL extension for Composer?

I am trying to use the PayPal PHP SDK to make an online store, however the documentation tells me I need composer. When I try to install composer I get this error. I have no idea what this means, or how to fix it. What can I do to fix this? I
P.S. There are quite a few questions about this on SO, however, all of them that I have seen ask about using WAMP or something similar. I have no intention of using WAMP, or anything like that. The only thing I am trying to do is install composer properly.
EDIT: I am just using the Composer installer for Windows.
You need PHP installed whether you have a full test environment running or not. If you can't run PHP from the command line Composer stuff doesn't work. With a basic install of PHP the openssl extension is included so that error would go away.
You can install PHP manually on its own, or you could just install WAMP or any of the many others. I use Zend Server myself. It just installs everything for you so that it works without needing to mess with manual installation.
Once PHP in general is installed, though, that should get rid of this error.

PHP Pear -- 'MDB2\Driver\mysql.php' missing

I've inherited a huge project, and I'm having a real time just trying to get the damned thing on its legs. Every time I run the project, amongst all the Strict Standards and Depreciated notices is one error:
Failed opening 'MDB2\Driver\mysql.php' for inclusion
From what I've read, DBMS drivers stopped being included in default Pear installations over five years ago... So how I can fix this so that either it doesn't use mysql.php anymore, or that my Pear installation DOES have it?
According to the Pear website, I just need to type: pear install MDB2_Driver_mysql but I'm wondering if it wouldn't just be better to change the code?
Thanks!
You say the project is huge, so I would suggest you don't rewrite it to use a different DB access library as that could push out your release date quite a bit and instead just install the required MDB2 driver.
To install the mysql driver, just do:
# pear install --alldeps MDB2_Driver_mysql
(and maybe consider using the mysqli driver instead)
If you do decide to migrate the project to use a different library, I'd suggest Doctrine as it is one of the mature DB libraries out there.
It sounds like you are trying to run PHP code written for an older version on a version of PHP that does not like some of the code.
Also see this for some insight on what you actually have to have installed on the PC running wamp in order to actually access a DB2 database. Are you sure you have all of this installed before you try to install via PECL?

Installing html_quickform2 with EasyPHP

I am using the most recent version of EasyPHP (a PHP 5.5 installation) as of this writing and it does not have Pear installed. That wasn't a problem until I read about html_quickform2 which seemed like a useful utility but I couldn't figure out how to add it to my project. It's installable via Pear but that's not included with EasyPHP anymore and I'm not sure how to set it up.
Does anyone know how to do this? Otherwise, is there a simple PHP library that allows me to just drop a couple of PHP files into my application instead?
See the installation instructions on the PEAR website.

How to install Zend Framework through PEAR using WAMPSERVER2.2 (64-bit)?

As the title states, I am having considerable problems in installing the Zend Framework through PEAR. After spending most of the day on this I'm quite surprised and frustrated with the lack of documentation, so as a result I was hoping the community would help me out.
Today I decided to change from XAMPP to WAMPSERVER2.2 for my development environment. After configuring the environment correctly and attempted to install Zend, I was dismayed to find that it does not come with the PEAR manager by default (that raises the question, why the hell not???). As a result I had to go download go-pear.phar and run the install under the command prompt >php go-pear.phar. All seems to run quite well... however, after adding the Zend channel zend.googlecode.com/svn trying to install the package via pear install zend/zend I run into problems, i.e. No releases available for package "zend.googlecode.com/svn/zend" install failed.
Tearing my hair out over this... could it be that pear was installed incorrectly? Why after adding the channel would the install fail? Any advice would be much appreciated.
You're getting upset about the wrong things. I hope I can give you a few clarifications.
PEAR installer and the WAMP (Windows Apache MySQL PHP) stack of your choice are not connected in any way and it is good, if such packages let you handle your own PEAR environment independently from it.
The time of XAMPP and WAMPSERVER are over, use Zend Server Community Edition, it's so much better, more stable, easier to set up, easier to configure.
Zend Framework is just a library, it doesn't need any installation. Why don't you just download it, place it wherever you like and put it on your PHP include path?
The installation over PEAR as you describe it, works for me, maybe you don't have the latest PEAR manager. Find out which PEAR version you have installed with pear list.
The most important point is. You only need to learn about the PHP include path and you can solve this problem in no time in any environment independently of any W/L AMP stack or PEAR installation.
I know its a bit late, but in case someone else runs into the same problem, this may help:
http://code.google.com/p/zend/issues/detail?id=25
It's basically a problem with pear and cache.

Categories