PHP-CLI changes the relative path such as "../yourdirectory/

General discussion on Zend Core for IBM System i

PHP-CLI changes the relative path such as "../yourdirectory/

Postby trapez01 on Fri May 20, 2011 1:54 am

When set up for the web - accessing different php scripts via Include() you can specific a relative path to the scripts location. For example you can include
another script, Include(../dir01/script01.php). The "../" means the directory dir01 is located up one directory level from your current location.

However, all this goes away when you use PHP-CLI. You have to specify the full location from the root, such as - Include("usr/local/zend/mydir/dir01/script01.php")

Is there a way to fix this???
trapez01
 
Posts: 3
Joined: Fri May 20, 2011 1:40 am

Re: PHP-CLI changes the relative path such as "../yourdirectory/

Postby erich_hieden on Fri May 20, 2011 8:23 am

It's not entirely true what you're saying. Of course you can use relative paths in php-cli as well. Just make sure that you start php-cli from the directory you want as current working directory.

Code: Select all
cd /www/zendcore/htdocs/<your-app-dir>
/usr/local/Zend/Core/bin/php-cli -f <your-app-entrypoint>.php >| <your-logfile> 2>&1


add '#! /QOpenSys/bin/sh' in the first line save it as *.sh and you can use it from the i5/OS command line with on call: CALL PGM(QP2SHELL) PARM('/www/zendcore/htdocs/<your-app-dir>/<your-shell-script>.sh')

Of course this can be done in ZendServer as well, just change the directories.
erich_hieden
 
Posts: 393
Joined: Tue Jul 07, 2009 9:01 am

Re: PHP-CLI changes the relative path such as "../yourdirectory/

Postby trapez01 on Tue May 24, 2011 12:47 am

thanks erich_hieden, its working great now ...and the script tip - was a bonus!
trapez01
 
Posts: 3
Joined: Fri May 20, 2011 1:40 am


Return to Zend Core for i5/OS

Who is online

Users browsing this forum: No registered users and 1 guest