psr-0

Why is underscore converted to directory separator in the PSR-0 standard?

落花浮王杯 提交于 2020-01-24 04:17:26
问题 The PSR-0 (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) standard specifies that an underscore in the class name should be converted to a directory separator in the corresponding file name. To me this does not seem to be a good idea as it creates lots of errors when someone who does not know the standard innocently uses an underscore in the class name and suddenly the autoloader cannot find the class and all sort of weird errors appear (see this stackoverflow issue

Laravel 4 Can't find BaseController from namespaced controller

六月ゝ 毕业季﹏ 提交于 2020-01-23 11:46:38
问题 I'm trying to structure my Laravel 4 site such that (1) major application groups' components (controllers/views/etc) are coupled together and (2) Laravel's supporting code outside of in my web server's document root. The default laravel home page loads fine, but I can't get a namespaced controller to route correctly. This is the relevant file structure: / [Project Root] /laravel [full laravel install here] composer.json /app /controllers BaseController.php /dev /htdocs index.php /app

Laravel 4 Can't find BaseController from namespaced controller

大兔子大兔子 提交于 2020-01-23 11:44:14
问题 I'm trying to structure my Laravel 4 site such that (1) major application groups' components (controllers/views/etc) are coupled together and (2) Laravel's supporting code outside of in my web server's document root. The default laravel home page loads fine, but I can't get a namespaced controller to route correctly. This is the relevant file structure: / [Project Root] /laravel [full laravel install here] composer.json /app /controllers BaseController.php /dev /htdocs index.php /app

Laravel 4 Can't find BaseController from namespaced controller

☆樱花仙子☆ 提交于 2020-01-23 11:44:03
问题 I'm trying to structure my Laravel 4 site such that (1) major application groups' components (controllers/views/etc) are coupled together and (2) Laravel's supporting code outside of in my web server's document root. The default laravel home page loads fine, but I can't get a namespaced controller to route correctly. This is the relevant file structure: / [Project Root] /laravel [full laravel install here] composer.json /app /controllers BaseController.php /dev /htdocs index.php /app

Laravel 4 Can't find BaseController from namespaced controller

℡╲_俬逩灬. 提交于 2020-01-23 11:43:10
问题 I'm trying to structure my Laravel 4 site such that (1) major application groups' components (controllers/views/etc) are coupled together and (2) Laravel's supporting code outside of in my web server's document root. The default laravel home page loads fine, but I can't get a namespaced controller to route correctly. This is the relevant file structure: / [Project Root] /laravel [full laravel install here] composer.json /app /controllers BaseController.php /dev /htdocs index.php /app

Composer Autoloading

不羁的心 提交于 2019-12-30 17:25:09
问题 I'm currently trying to use PSR-0 autoloading with Composer, but I'm getting the following error: Fatal error: Class 'Twitter\Twitter' not found My directory structure looks like this - Project - src - Twitter Twitter.php - vendor - Test index.php My index.php file looks like this: <?php use Twitter; $twitter = new Twitter(); My Twitter.php file looks like this <?php namespace Twitter; class Twitter { public function __construct() { // Code Here } } And finally my composer.json looks like

Does PHP's use statement cause extra work when loading classes?

旧巷老猫 提交于 2019-12-23 13:57:07
问题 Code Sample 1 use Outline\Drawing; $var = new Drawing(); Code Sample 2 $var = new Outline\Drawing(); Question: Does PHP make hardware work harder (look up more files or do more processing) if I use code in sample 1? I am sure something gets done, even if it is at the level of some code that figures out which use line gets matched up with which class. I want to find out exactly what is happenning. In short: What does PHP do when working out the connection between the use of the use statement

PHP 5.3 autoloader

隐身守侯 提交于 2019-12-22 12:48:07
问题 I would like to use the PSR-0 Standard way to autoload classes without requiring to add includes, e.g. how can I replace the code below with the autoloading mechanism: namespace Example; use MyLib\Controller; include_once './library/MyLib/Controller/AbstractController.php'; class MyController extends Controller\AbstractController { [...] So in the example above, it shows that in every controllers I need to include the abstract controller, which is crazy... I have found the PSR-0 code here:

PHP - most lightweight psr-0 compliant autoloader

允我心安 提交于 2019-12-17 09:33:55
问题 I have a tiny application that i need an autoloader for. I could easily use the symfony2 class loader but it seems like overkill. Is there a stable extremely lightweight psr-0 autloader out there? 回答1: You ask extremely lightweight, let's do so ;) Timothy Boronczyk wrote a nice minimal SPL autoloader : http://zaemis.blogspot.fr/2012/05/writing-minimal-psr-0-autoloader.html I condensed the code like this: function autoload1( $class ) { preg_match('/^(.+)?([^\\\\]+)$/U', ltrim( $class, '\\' ),

Symfony ClassLoader wont load

风流意气都作罢 提交于 2019-12-13 20:25:26
问题 iam developing small php framework for personal use.Iam trying to autoload classes with UniversalClassLoaderwich is used in Symfony.But when i try to use some these clases i got error Fatal error: Class 'Controller' not found in /opt/lampp/htdocs/web/globeapi/Start.php on line 14 Here is Start.php file code. require('../libraries/loader/Loader.php'); use Symfony\Component\ClassLoader\UniversalClassLoader; $auto = require('../config/Auto.php'); $Loader = new UniversalClassLoader(); $Loader-