Search code examples
zend-framework2cpanel

Zendframework 2 on cPanel


I'm trying to install zf2 on cpanel in a subdomain. www.domain.ro/test. I extracted zip file in directory public_html/test. So I have in test/zf folder structure:

bin
library
resources
composer.json
...

in public_html/test I have the php.ini with include_path:

include_path = ".:/usr/lib/php:/usr/local/lib/php:/home/cPanelUsername/public_html/test/zf/library"

For testing if zf2 is installed correctly, I create a zend-test.php with lines:

<?
phpinfo();
require_once 'Zend/Mail.php';
$mail=new Zend_Mail();
echo 'it is working';
?>

And I have error:

Warning: require_once(Zend/Mail.php): failed to open stream: No such file or directory in /home/cPanelUsername/public_html/test/zend-test.php on line 3
Fatal error: require_once(): Failed opening required 'Zend/Mail.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/cPanelUsername/public_html/test/zf/library') in /home/cPanelUsername/public_html/test/zend-test.php on line 3

Solution

  • I succeded using ZF2_PATH environemnt variable. In directory public_html/test I create an index.php file with lines:

    putenv( "ZF2_PATH=/home/cPanelUsername/public_html/test/zf/library");
    include "zf/application/public/index.php"; 
    

    And I create application folder in zf folder. Application folder has structure :

    config
    data
    module
    public
    

    This way the problem was solved. I can use zf2 on cPanel with a subdomain like www.domain.com/test, for testing propose.