php - Zend Framework 2 including custom library -
my directory construction this:
c:\workspaces\zend c:\workspaces\custom librarycustom library shared library, in utilize in other applications. doesn't utilize namespaces, old style underscores.
i downloaded zf2-restful-module-skeleton intend utilize restful server. in infocontroller have code:
namespace main\controller; utilize zend\mvc\controller\abstractrestfulcontroller; class infocontroller extends abstractrestfulcontroller { public function getlist() { $data = array( 'phone' => '+30123456789', 'email' => 'email@domain', ); $res = new cl_res_chain_mutable(); homecoming $data; } }
error message is:
fatal error: class 'main\controller\cl_res_chain_mutable' not found in c:\workspaces\zend\module\main\src\main\controller\infocontroller.php
obviously, need add together custom library zend application, im "little" lost here, don't know how this. have googled couple solutions, none of them seem this.
also, have library in folder c:\workspaces\custom library 2
, has (among other files) file(class) d.php, have used d::dump($data);
how can work in zend application that?
you need configure standardautoloader
load library classes. easiest way modify application module's module::getautoloaderconfig()
method looks this:
public function getautoloaderconfig() { homecoming array( 'zend\loader\standardautoloader' => array( 'namespaces' => array( __namespace__ => __dir__ . '/src/' . __namespace__, ), 'prefixes' => array( 'cl' => 'c:\\workspaces\\custom library/cl', 'd' => 'c:\\workspaces\\custom library 2/d', ), ), ); }
i've added prefixes
key , listed prefix name , find on disk. standard autoloader documentation has more details.
if working zend skeleton application may add together these namespaces init_autoloader.php file.
php zend-framework2
No comments:
Post a Comment