autoloader

PHP: autoloader can't find the file

。_饼干妹妹 提交于 2019-12-12 01:53:53
问题 I'm using autoloader to load classes by their namespaces, it's working fine on localhost but not on server online. When Autoloader.php loads classes PHP shows me this error : Warning: require(\..\backoffice\controllers\EquipementsManager.php) failed to open stream: No such file or directory But I'm sure the path is correct and the file EquipementsManager.php exists in this path !Which means the autoloader is loading classes properly with the right path but PHP keeps giving me No such file or

PHP: Autoloading PEAR namespaced classes within PSR-0 namespaced classes conflict

谁说胖子不能爱 提交于 2019-12-11 13:52:53
问题 For my application I am using PSR-0 namespaces. Everything works beautiful! Until I wanted to use Twig as template parser, Twig uses PEAR pseudo namespaces. Like Twig_Loader_Filesystem. The problem is that when I want to use Twig inside my name-spaced application like this: <?php namespace Tact\ViewManager; class ViewManager { public function init() { $loader = new Twig_Loader_Filesystem($this->templatepath); $this->twig = new Twig_Environment($loader); } } ?> PHP will tell my autoloader to

Object not being destroyed until end of the script if it registers spl_autoload_register();

不问归期 提交于 2019-12-11 04:29:54
问题 Object not being destroyed before script ends can someone explain why using spl_autoload_register() prevents object from destruction when unset() . The destructor method will be called as soon as there are no other references to a particular object, or in any order during the shutdown sequence. Does spl_autoload_register() have reference to the object that registered it or what happens? class MyAutoLoader { public function registerAutoLoader() { spl_autoload_register(function ($class) { }); }

How use custom libraries in Kohana 3

南笙酒味 提交于 2019-12-11 03:19:40
问题 I am trying to include a user library that includes some user related functions such as checking if the user is authenticated and such. Now I am trying to make usage of the Kohana autoloader, but can't seem to get it working. I have the library placed under application/classes/library class User { public function is_alive() { $session = Session::instance(); $data = $session->get('alive'); if(isset($data)) { return true; } else { return false; } } } And I try to call the library with $user =

Composer PSR-4 autoloading “class not found” debug

好久不见. 提交于 2019-12-11 02:44:01
问题 Yes another question about the "class not found" error. Either I am missing something, or I misunderstood the PSR-4 logic. My composer library directory sturcture: "Scanner" => "src" => "Test.php" Test.php namespace MyNS; class Test { } composer.json "autoload": { "psr-4": { "MyNS\\": "src/" }, } So, now I load the library in my project with composer and try using it. require_once("../vendor/autoload.php"); $test = new MyNS\Test(); Which always results in "Fatal error: Uncaught Error: Class

I'm trying to configure behat and seeing an error - failed to open stream: No such file or directory in /usr/bin/behat

∥☆過路亽.° 提交于 2019-12-11 01:36:29
问题 PHP Warning: require_once(behat/autoload.php): failed to open stream: No such file or directory in /usr/bin/behat on line 23 PHP Fatal error: require_once(): Failed opening required 'behat/autoload.php' (include_path='.:/usr/bin/pear:/usr/lib/php:/Users/steve/perforce/') in /usr/bin/behat on line 23 Any ideas what might be causing this?? 回答1: do you have the file at one of the following places :/usr/bin/pear/behat/autoload.php OR :/usr/lib/php/behat/autoload.php: OR /Users/steve/perforce

Symfony2 - Composer class loader instance in controller

Deadly 提交于 2019-12-11 01:05:56
问题 Is there a way to get the composer autoloader instance inside a Symfony2 Controller? 回答1: Yes - there is a way. And assuming that you want to know how to actually get the loader then you can do this in your controller: class MyController function myAction() { die(get_class($GLOBALS['loader'])); // Composer\Autoload\ClassLoader Should you do this? Probably not. In most cases you can tweak the loader in the app/autoload.php file. 回答2: Using the $GLOBALS did not work for me, but you can also get

form_validation class does not load (codeigniter)

依然范特西╮ 提交于 2019-12-10 17:45:41
问题 My script fails to load form_validation class. I called it from autoload.php, controller's _ construct method and the method i was intend to use ( ie. login() method ) autoload.php $autoload['libraries'] = array('database', 'Login', 'Template', 'form_validation', 'session'); controller <?php class Login extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('user_model'); $this->load->library('form_validation'); } function logmein() { $this->load->library(

How to define custom autoloader in composer?

吃可爱长大的小学妹 提交于 2019-12-10 13:15:47
问题 I am using Nette Framework which uses its own autoloader. How can I define custom autoloader or just exclude the standard one from composer so I can use my own? 回答1: Simply don't include it if you don't want to use it. Keep in mind you'll have to handle autoloading on your own. If your autoloader can work with it, you can use namespaces file generated by composer: Composer provides its own autoloader. If you don't want to use that one, you can just include vendor/composer/autoload_namespaces

Class Comment not found Laravel 4

 ̄綄美尐妖づ 提交于 2019-12-08 13:41:22
问题 Im trying to add a comment system to my laravel app. But I can't seem to get it working. I have two models class Post extends \Eloquent { protected $table = 'posts'; public function comments() { return $this->hasMany('Comment','postId'); } } and my Comment model class Comment extends \Eloquent { protected $table = 'comments'; public function post() { return $this->belongsTo('Post'); } } in my DashBoardController I'm trying to get the output from the models use App\Models\Post; use App\Models