autoload

Yii import or include

一世执手 提交于 2019-12-22 04:45:12
问题 I encountered a problem about importing php files. Why this works: include( Yii::getPathOfAlias( 'ext.payu.payU').'.php' ); but that don't: Yii::import( 'ext.payu.payU'); ? file payU.php: include_once( dirname(__FILE__) . "/sdk/openpayu.php"); //this is a valid path class payU{ } 回答1: Try to do Yii::import('ext.payu.payU', true) because default one-parameter Yii::import() function call means: hey, just add this path to the known aliases list and do not require() it now and you have to do new

Composer vs Symfony 2 autoloader

狂风中的少年 提交于 2019-12-21 07:58:07
问题 I'm starting to use Composer in a project, in which I historically had all the dependencies under version control. This project currently uses the Symfony 2 autoloader. Because Composer comes with its own autoloading mechanism ( vendor/autoload.php ), that makes me wonder if I still need to use the Symfony ClassLoader. I assume that I could just use the Composer autoloader to autoload my project classes as well: $loader = require 'vendor/autoload.php'; $loader->add('MyProject', 'src'); Is

How do I include or autoload external libraries in a TYPO3 Extbase Extension? + Dependecy Injection?

你离开我真会死。 提交于 2019-12-21 05:27:24
问题 I'm developing a TYPO3 4.6 Extension with Extbase 1.4 and im trying to include an external library. The library, in my case the facebook PHP SDK, is under $_EXTKEY/Resources/PHP/facebook-php-sdk/facebook.php . I would like the library to autoload and automatically inject (Dependecy Injection) where I need it. Some comments I found online suggest that one should include libraries with require_once(): http://forge.typo3.org/issues/33142 if it's just a tiny helper library, it's intended to be

Namespace Autoload works under windows, but not on Linux

安稳与你 提交于 2019-12-21 03:53:33
问题 I have the following php code: index.php <?php spl_autoload_extensions(".php"); spl_autoload_register(); use modules\standard as std; $handler = new std\handler(); $handler->delegate(); ?> modules\standard\handler.php <?php namespace modules\standard { class handler { function delegate(){ echo 'Hello from delegation!'; } } } ?> Under Windows 7, running WAMP, the code produces the message "Hello from Delegation!" however under Linux, I get the following: Fatal error: spl_autoload(): Class

Composer autoload file not working

有些话、适合烂在心里 提交于 2019-12-20 07:12:13
问题 My Autoload specification are as follows "autoload" : { "psr-4" : { "MyMVC\\" : "app/" }, "classmap": [ "app/Controllers", "app/Helpers" ], "files": ["app/routes.php"] }, The contents of routes.php file are: <?php use MyMVC\Core\Route; $route = new Route; $route->add('/', 'HomeController@index'); $route->add('about', 'AboutController@index'); $route->add('contact', 'ContactController@index'); now in my app/init.php i am trying to use the $route object but its giving me error Notice: Undefined

PSR-4 autoloading not working

可紊 提交于 2019-12-20 01:41:27
问题 I have created an app/modules directory and autoloaded it using PSR-4 like this: "psr-4": { "Modules\\": "app/modules" } And I also did composer dumpautoload . I have the following directory structure: app - ... - modules -- ModuleName --- controllers ---- BackendController.php ... The file BackendController.php has the namespace Modules\ModuleName\Controllers . And in routes.php , I have the following: Route::resource('backend/modules/module-name', 'Modules\ModuleName\Controllers

Rails: uninitialized constant just happen on production server

浪子不回头ぞ 提交于 2019-12-19 19:57:33
问题 I have a class that I put inside lib/network : module NetworkApi class NetworkProxy end end Then in another class, I referenced this class: network_proxy = ::NetworkApi::NetworkProxy.new(params) Everything runs normally on my development environment, but when I deploy to the server, I get an error at the above line with the message: NameError: uninitialized constant NetworkApi::NetworkProxy I don't know why this strange error happens. Please tell me why. 回答1: Note that Rails 5 disables

Rails: uninitialized constant just happen on production server

大兔子大兔子 提交于 2019-12-19 19:56:03
问题 I have a class that I put inside lib/network : module NetworkApi class NetworkProxy end end Then in another class, I referenced this class: network_proxy = ::NetworkApi::NetworkProxy.new(params) Everything runs normally on my development environment, but when I deploy to the server, I get an error at the above line with the message: NameError: uninitialized constant NetworkApi::NetworkProxy I don't know why this strange error happens. Please tell me why. 回答1: Note that Rails 5 disables

composer package testing bootstrap

女生的网名这么多〃 提交于 2019-12-19 18:58:18
问题 I've written a package and as part of the development proccess I want to run unit tests on it. This basically means I need a bootstrap file to register the autoloader for my package. Any package I look at doesn't have a specific bootstrap file, thus I don't quite understand how the developers are testing their own packages. This is my directory structure src .CompanyName ..PackageName ...Class 1 ...Class 2 tests .Class1Test .Class2Test composer.json phpunit.xml.dist Now if I run phpunit

iphone navigationController autoloading to three level

杀马特。学长 韩版系。学妹 提交于 2019-12-19 11:57:52
问题 i create i navigationController project name:autoload, then create two uiviewContorller named: second,three i want the process is load rootView the load second in method:"viewDidLoad" then auto load three in method"viewdidload", here is the code: rootView: - (void)viewDidLoad { self.title = @"first"; Second *second = [[Second alloc] init]; AutoLoadAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.navigationController pushViewController:second animated:YES];