php - How to include a class in CakePHP 2.x -
this basic question can't figure out.
i have class named myclass.php, standalone php script contains standard object definition this:
<?php class myclass { public function myfunction($param1, $param2){ return $param1*$param2; } }
all want able call class model, app/models/mymodel.php able $myclass = new myclass();
where should store myclass.php in file structure , how can make visible mymodel?
thanks!
you'll note have 'vendors' directory inside root (ie, on same level 'app' folder). placing non-cakephp related files shared across applications. have 'app/vendor' directory, storing non-cakephp files specific 1 app.
so, should go in 1 of these 2 directories - likely, in app/vendor.
there's little bit know loading vendor files - can read details here.
in case, need:
app::uses('myclass', 'vendor');
Comments
Post a Comment