autoload

composer does not autoload

你说的曾经没有我的故事 提交于 2019-12-04 06:10:37
问题 I followed the composer instructions and installed composer successfully. I want to use tumblr's brand new php api client. My folder structure: vendor/ composer.json composer.lock myfile.php composer.json : { "require": { "tumblr/tumblr": "0.0.2" } } myfile.php : require 'vendor/autoload.php'; $client = new Tumblr\API\Client(CONSUMER_KEY, CONSUMER_SECRET); Installing using php composer.phar install works great as well. But when executing myfile.php the class could not be found. Fatal error:

autloading not working correct using autoloader.php in vendor directory

£可爱£侵袭症+ 提交于 2019-12-04 05:43:49
i've troube with the autoloading of composer as the autoloader can't resolve Doctrine\ORM\Mapping\Table. For the Unittests i have created doctrine entity classes with typical Annotations: <?php namespace OmniSearchTest\Entity; use Doctrine\ORM\Mapping as ORM; /** * Picture * * @ORM\Table(name="picture") * @ORM\Entity */ class Picture { and created a new entity manager by using this entities. But im getting The Message: Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@Doctrine\ORM\Mapping\Table" in class OmniSearchTest\Entity\Picture does not exist, or could

Check whether instance of a class exists, if not create an instance

a 夏天 提交于 2019-12-04 03:23:52
I was wondering if it's possible to create a function and pass it a class name. The function then checks if an instance of the class currently exists, if it does not it create an instance of the class. Furthermore if possible make that variable global and require it to be returned. I realize that returning may be the only option. function ($class_name) { // Check if Exists // __autoload will automatically include the file // If it does not create a variable where the say '$people = new people();' $class_name = new $class_name(); // Then if possible make this variable a globally accessible var.

Why doesn't PHP's Autoload feature work in CLI mode?

♀尐吖头ヾ 提交于 2019-12-04 03:08:49
问题 This is more for my own personal edification than anything else but, this is something that has always bothered me: Why specifically can't PHP perform "autoloading" while in CLI mode? I've been reading this disclaimer for years, but I've never read anything that touches on why: http://php.net/manual/en/language.oop5.autoload.php: Note: Autoloading is not available if using PHP in CLI interactive mode. Does anyone know what is preventing PHP, as a language, from autoloading while working in

Composer vs Symfony 2 autoloader

可紊 提交于 2019-12-04 02:08:34
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 there any drawback in using the Composer autoloader for the whole project? Are there features the Symfony

Composer Not Generating Autoloads For Library

我的梦境 提交于 2019-12-04 00:16:19
问题 I've set up two projects, an 'init' and a library, which is required by the init. They both have PSR-0 autoloads set, but the autoload values from the library are not added to the vendor/composer/autoload_namespaces.php in the init project. Sample composer.json from the Library: { "name": "lxp/library", "description": "A test library", "autoload": { "psr-0": { "LXP\\Library": "src/" } } } Sample composer.json from the project that requires that library: { "name": "lxp/init", "name": "A test

Rails unable to autoload constant from file despite being defined in that file

丶灬走出姿态 提交于 2019-12-03 22:59:16
This is a tricky one to explain. I have a module in another module namespace like so: # app/models/points/calculator.rb module Points module Calculator def self.included(base) base.send(:include, CommonMethods) base.send(:include, "Points::Calculator::#{base}Methods".constantize) end end end So then in other classes all I need to do is: class User include Points::Calculator end I've specified this directory in application.rb to be autoloadable...(even though i think rails recurses through models...) config.autoload_paths += Dir[ Rails.root.join('app', 'models', "points") ] In development env,

use PHPExcel with composer and Symfony2.2

﹥>﹥吖頭↗ 提交于 2019-12-03 21:36:02
问题 I found this on SO: How to use PHPExcel correctly with Symfony 2 This works, but I want to use it with composer. The first part I already solved: to load PHPExcel for a special tag (the last stable release) I don't find out how to fetch a tag with this syntax: "repositories": [ { "type": "vcs", "url": "https://github.com/umpirsky/SyliusAssortmentBundle" } ] So I use the Package notation: I found out, the reference should be the tag name on github. And the version cannot be the same value

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

本小妞迷上赌 提交于 2019-12-03 17:41:32
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 stored in {PackageRoot}/Resources/PHP/{libraryName} and just included via require. is this suspected by

autoload and namespaces

你离开我真会死。 提交于 2019-12-03 17:20:31
I've been working with PHP for a long time, but am now starting to experiment with newer language features such as namespaces. I have a question regarding autoloading that I haven't been able to find an adequate answer to in my web searching. Suppose I have classes in different namespaces: namespace foo\bar\baz; class Quux { } namespace fred\barney\wilma; class Betty { } Then suppose I had an autoloader that assumes that there's a 1:1 mapping between namespaces and directory structures: function autoload ($className) { $className = str_replace ('\\', DIRECTORY_SEPERATOR, $className); include (