PHPUnit setup with Zend 1.12.3 - macos

I am just getting start with Zend Framework and seem to run into this problem
Testing Note: PHPUnit was not found in your include_path, therefore no
testing actions will be created.
I am on mac 10.8.5, Using Zend Server 6 (free), and Zend Framework 1.12.3
Have pear and phpunit installed
which pear
/usr/local/zend/bin/pear
which phpunit
/usr/local/zend/bin/phpunit
from php info and include_path
Loaded Configuration File /usr/local/zend/etc/php.ini
include_path=".:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/bin/pear:/usr/local/zend/bin/phpunit:/usr/local/zend/share/pear:/usr/local/zend/share/pear/phpunit"
No matter what i put in the include_path, i always get the above notice, PHPUnit was not found in your include path.
I been searching and someone said zf.ini can cause this, and that file should be editted, however i can't seem to find such a file anywhere on my Mac. I do have previous Mamp and Xampp installations, but phpinfo() states the correct php.ini file loaded so i doubt that is the problem
Edit:
Okay so i finally managed to fix it. Using "zf.sh --setup" i found the paths to all the config files, including .zf.ini and how to edit it. The file did not exist, so i had to create it, and adding "include_path" to .zf.ini fixed the issue. However in the end i am overriding the php.ini which was probably being over ridden. I still like to know why adding pear path to php.ini didn't work, hopefully someone can explain that

Related

PHP Warning: PHP Startup: Failed to load , The system cannot find the file specified. PHP 7.4 Windows

Before marking this as a duplicate, hear me out :)
I have some years experience working with PHP on windows, and have even created a portable (for Windows) distribution of an AMP stack: https://thejaka.com/tzwamp/ which I named "WAMP Zero" or TZWAMP. I've used this WAMP distro extensively, and people I know are using it as well. The last (previous) distribution works fine, but when I tried to update the distro to the latest builds of the applications/components from the vendor/distributor sites, I hit a snag. The PHP extensions aren't loading anymore on the new distro. It seems one or more dependencies are not locatable but I don't know what or where from. I tried viewing php_mbstring.dll in a dependency viewer, but couldn't figure out what was the matter. There were a few missing dependencies, but most seemed to be from CRT and I've installed the latest. I'm guessing the missing dependencies can be resolved from PATH environment variable. The following are not loading:
php_mbstring.dll php_mysqli.dll php_openssl.dll php_pdo_mysql.dll
php_mbstring.dll php_mysqli.dll php_openssl.dll php_pdo_mysql.dll
The error messages are like: PHP Warning: PHP Startup: Failed to load ......\php\ext\php_mbstring.dll, The system cannot find the file specified.
Before you start complaining about the relative path, note that on 7.3 it worked fine.
The path to the ext dir is specified relatively, but the path seems to be correct. The same path worked fine in the previous distro of TZWAMP, and when I change the path, the error messages also change leading me to believe the path is correct. Note also that I tried adding php path to PATH environment variable as well.
The successfully working PHP version is 7.3.10.
The problematic PHP version is 7.4.2.
Apache version is 2.4.41
Is anyone aware of any relevant change from 7.3.* to 7.4.*, or else can anyone help me debug the issue and resolve it?
EDIT: I've checked and an absolute path seems to work. However, in order to make this portable, a relative path is required. Relative paths worked with 7.3 and I believe prior major versions. Any ideas?
I've solved this for now to my requirements by using an Environment Variable substitution.
extension_dir = "${P}\php\ext"
However, a relative path solution would also be welcome.

Installing YAML for PHP in IIS

I am trying to install the YAML 1.2 extension to PHP 5.6 under IIS 10 (Windows 10). I am using http://pecl.php.net/package/yaml/1.2.0/windows to download the files.
I have downloaded the PHP 5.6 non-thread-safe DLL (x86 to match my version of PHP), copied php_yaml.dll to my extension directory, copied yaml.dll to C:\Windows\System32 (which is reported as one of the paths in phpinfo()) and added extension=php_yaml.dll to my php.ini. I've verified with phpinfo() that the correct php.ini file is being loaded, and commenting out other extensions removes them from the output of phpinfo().
However, YAML doesn't appear in the output of phpinfo() and the functions are not loaded. Running php-cgi.exe -v from the command line gives a warning:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\PHP\php_5_06_14\ext\php_yaml.dll' - The specified module could not be found.
in Unknown on line 0
The file exists at the location specified and the permissions appear to be correct. What else can I do to get it working?
As far as I can tell, the use of PECL as package manager is being in dropping.
Having to install extensions in a server makes things more complicated and it depends on the environment, permissions, etc.
I'm sure someone could help you solve that (I haven't work on windows in years, so I can't)
But, instead I suggest you another solution. Maybe you can opt for it, maybe you have to stick with the extension, but, in case you can actually look for other option, I suggest you to use another library.
https://github.com/symfony/yaml
And, you could use Composer to install your libraries, I suggest you take a look at it.
Again, it may be for you or not, but I think this would be a lot easier.
I hope that helps.
I put the path to my extension directory in the path environment variable. That fixed the issue for me.

Undefined Class Error in Smarty using PHPStorm 10

I have mac, installed PHPstorm 10, now trying to install smarty, similar to as mentioned in following tutorial , http://phpwebscript.blogspot.com/2009/09/smarty-installation-steps-on-wamp-and.html,
i have installed mamp supporting PHP 5.6. everthing is configured file. as mentioned in the tutorial i have edited php.ini file under correct version. After everything is setup i get error on following;
require ('/Applications/MAMP/Smarty/libs/Smarty.class.php');
$smarty =new Smarty() //Undefined class smarty error;
When i run,
echo (defined('SMARTY_DIR') ? 'Yes' : 'No');
i get yes
any fix please.
I have solved this issue, following were the problems that i fixed,
Include path was not set, i though i have included path in php.ini now its ok, but when you create a project in phpstorm or netbeans, there is a folder created external libraries or include path, you have to include smarty, I did it and now everything ok
i had copied testinsall from net which was causing error, retyped it and now smarty is running perfect on phpstorm 10.

Installing Zend Framework 2 on XAMPP in Windows

I know this question may have appeared few times here and in the internet. But still I feel it is not clear for somebody who wanted to enter into the world of frameworks. I have followed these links Rob Allens Tutorial, ZF Quick Tutorial.
But some how I feel it is not quite clear with the installation part. I have a windows system basically Vista with the newest version of XAMPP installed. I have downloaded the latest version of ZFSkeletonApplication from this link ZFSkeletonApp, extracted the skeleton contents, renamed the folder to zendframework and moved it to xampp folder i.e now ZF skeleton is in c:\xampp\zendframework.
So until here everything seems clear and easy, from here I am some how lost with the configurations. Can some one elaborate the things from here how to install the Zf and make it work, like changes in the include paths, .htaccess files and so on. Please do remember that I have windows with XAMPP on it. If some one can guide me exactly for this set up, it would be helpful.
P.S. It would be good if one can provide info about the changes which I need to make with examples consisting of paths, so that I am not lost, for example like you can find .htaccess file here(ex pathname), changes in .htaccess file should be so and so.
Thanks
For future references, i also made a big post on how to install ZF2 on a windows xampp environment right here Install ZF2 on Windows Xampp
OK, i have done this on multiple systems now. For a home system the following steps work quite well:
Download msysGit and install it to any directory
Run the git-cmd.bat from the msysGit-Folder
Move into the directory you want i.e. C:\xampp\htdocs\ (this is done via cd dirname or cd .. to go up a level, change partition with D: and hit enter)
Run the following command. The <OptionalFolderName> would be the name of a Sub-Directory of htdocs, if you skip this, the folder will get named ZendSkeletonApplication
git clone git://github.com/zendframework/ZendSkeletonApplication.git <OptionalFolderName>
Possible Trouble Scenario (fatal:unable to connect to github.com)
Once again at workplaces, pretty often the default port (9418) for the git-protocol is blocked. If this is the case for you, then you should try one of the following Commands
git clone https://github.com/zendframework/ZendSkeletonApplication.git <OptionalFolderName>
git clone git#github.com:zendframework/ZendSkeletonApplication.git <OptionalFolderName>
Now you are not done yet. The skeleton Application is installed, but the framework is still missing, here some people might run into the first problems, but this actually is quite easy.
We're still at the command line interface
cd <OptionalFolderName> or cd ZendSkeletonApplication depending on what you did earlier
php composer.phar self-update
php composer.phar install (this might take a while)
So, this is the part where lots of things can happen. I have two scenarios happened to me:
Scenario #1 No directory write permissions
This is easily handled by running the command line interface with administrator privileges
Scenario #2 Working behind a router (i.e. at work)
Personally i didn't have to do much to get this working, but the line might change depending on your proxy. Personally i did the following at the command line interface
SET HTTP_PROXY=http://proxy.domain.tld:8080 you might also be good with
SET HTTP_PROXY=proxy.domain.tld:8080 don't ask me why, but i needed the http://
With all those done, you should have an almost running ZendSkeletonApplication. The other part is how to set up your virtual host, but i won't go into detail on this, as that's even ZF1 Stuff and everyone should be familiar with that by now, if not, there's good resources to learn out there.
I hope i could be of help to you.
Setbacks have to install in Windows, but I ended up finding a solution. From ZF2 to install on windows via git, for this is the only use that simulates msysGit git linux on windows, for it is only access the tutorial: http://zf2.com.br/tutoriais/post/instalando-o-git-no-windows-para-fazer-a-instalacao-do-zf2-somente-no-comando-do-windows-via-composer
Since I had lot dependency extension problems (mostly .dll files) with old version of XAMPP, so first thing I did was made sure I uninstall all previous versions of PHP already present on my system as well as old XAMPP. Then installed latest XAMPP v3.2.2 (using latest XAMPP 3.2.2-32-bit on Win-7-64-bit). Then followed installation steps in XAMPP Documentation under title Start a New Zend Framework 2 Project.
I had issues while installing composer also with old-XAMPP, but somehow those errors didn't appear during composer installation this time. And, I successfully installed ZEND till I typed http://localhost:8081/myapp/ (I renamed my ZendSkeletonAppliction folder as myapp as per documentation) into my browser to access the same and met the error which said:
Fatal error: Uncaught RuntimeException: Unable to load ZF2. Run php composer.phar install or define a ZF2_PATH environment variable. in C:\xampp\apps\myapp\htdocs\init_autoloader.php:51
Stack trace:
#0 C:\xampp\apps\myapp\htdocs\public\index.php(18): require()
#1 {main} thrown in C:\xampp\apps\myapp\htdocs\init_autoloader.php on line 51
Composer.phar was not even present the first time I downloaded ZendSkeletonApplication‐master.zip from Github (there was only composer.json and composer.lock files present). Anyhow I didn't need them since I followed XAMPP Doc which doesn't call composer.phar in command line:
composer create‐project ‐s dev zendframework/skeleton‐application path/to/install
I am not that tech-savvy to know how to 'define a ZF2_PATH environment variable' correctly, so I wasted time looking for solution online, couldn't find any (which is when I stumbled on this forum which also turned out not to have a solution for my query). In the end, in a fit of depression and anxiety, serendipity happened. All I did was as per XAMPP's ZEND documentation I right-clicked inside C:\xampp\apps\myapp\htdocs folder and clicked 'Composer Install' which reinstalled the Zend files from cache. Then refreshed http://localhost:8081/myapp/ and the Zend intro page appeared.
I just did it like that:
D:\web_dev\zendapp>C:\PHP\php.exe composer.phar self-update
it worked perfectly

I cant get PHPUnit to work within NetBeans (Mac)

My NetBeans have an option to add a path to a script that runs PHPUnit, however when I try to add this script to my NetBeans I get the error that it doesn't recognize the version. Says that version is ?.?.? and that is not supported. However my PHPUnit version is supported by NetBeans and work perfectly when I run it from the pear installer folder (PHP).
"Selected PHPUnit (version ?.?.?) is too old, upgrade it if possible (the minimum version is 3.3.0)" - I got 3.6.4.
My script looks like this
#!/bin/sh
phpunit --bootstrap MyBootstrap.php --stderr $*
And it works great on linux NetBeans. Just not on my Mac.
And yes it works perfect when I run it in the console.
Thanks a milion
/Marcus
I'm not sure what php runner is, but to recognize valid PhpUnit, NetBeans run command "phpunit --version", so check what this command gives you in console.
Once I had problem with this, so I simply found the code of phpunit that is responsible for "phpunit --version" and manually type what should be printed when this command is executed. So NetBeans "saw" correct version and everybody is happy :)
I solved the phpunit problem (too old phpunit message on netbeans)
First open terminal and then:
cd /private/etc
cp php.ini.default php.ini
open php.ini file
change include_path to include_path = ".:/usr/share/pear"
Problem solved :)
If however the problem is not solved then try install netbeans for php from netbeans.org
Mate, that is error by Netbeans (see bug id 188240), and it looks like it is not fixed yet. It happens on Mac OSX.
What i did is to rename Application/NetBeans/NetBeans 7.1.1 to Application/NetBeans/NetBeans7.1.1 (note the lack of space)
as per Xdebug, read this:
http://xdebug.org/find-binary.php
when you get the version for your server, add these lines into your php.ini:
zend_extension = /opt/local/lib/php/extensions/<name of your extension>/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
replacing <name of your extension> with, of course, the name of your extension :)
after this you should be ready to go.
Issue about version soved by reinstalling everything, however I now get this
PHPUnit 3.6.7 by Sebastian Bergmann.
The Xdebug extension is not loaded. No code coverage will be generated.
Cannot open file "/Applications/NetBeans/NetBeans".
How could I load Xdebug? Is that in php.ini or apache conf? or is that in NetBeans?

Resources