autoload

use PHPExcel with composer and Symfony2.2

我们两清 提交于 2019-11-30 22:54:10
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 (PHPExcel_1.7.8). Seems that alphabetical characters are not allowed, so it's only the version as a number

Replacement for PHP's __autoload function?

ぃ、小莉子 提交于 2019-11-30 19:40:54
I have read about dynamically loading your class files when needed in a function like this: function __autoload($className) { include("classes/$className.class.php"); } $obj = new DB(); Which will automatically load DB.class.php when you make a new instance of that class, but I also read in a few articles that it is bad to use this as it's a global function and any libraries that you bring into your project that have an __autoload() function will mess it up. So does anyone know of a solution? Perhaps another way to achieve the same effect as __autoload() ? Until I find a suitable solution I'll

Unexpected character in input: '\' (ASCII=92) state=1 in a Silex Application

非 Y 不嫁゛ 提交于 2019-11-30 16:42:59
问题 I moved my website from local to a hosting, and something happened to me. I include this config file into my index.php (it's the first thing I do): <?php require_once __DIR__.'/../../vendor/autoload.php'; // some other stuff $app = new Silex\Application(); $app['debug'] = true; $defaultLocale = 'en'; $app->register(new Silex\Provider\TwigServiceProvider(), array( 'twig.path' => array( __DIR__.'/../views', __DIR__.'/../views/backend', __DIR__.'/../views/layouts', __DIR__.'/../views/components'

One shared vendor with two projects

感情迁移 提交于 2019-11-30 09:16:09
问题 I'm working on 2 applications right now. The first one is a CMS, and the second is a shop. I want to move my vendor one level above and the share it between projects. So my structure will be something like this: project1/ project2/ shared_vendor/ I read about this. I have changed the app/autoload.php loader variable from: $loader = require __DIR__.'/../vendor/autoload.php'; to: $loader = require __DIR__.'/../../vendor/autoload.php'; And I have also changed vendor-dir in my composer.json from:

PSR-4 autoloading with Composer

允我心安 提交于 2019-11-30 08:34:27
I run a portail with composer's autoloading class system: "autoload": { "psr-4": { "Portal\\": "src/" } } It works when I run composer.phar dump -o , for instance my class Boostrap is well referenced into vendor/composer/autoload_classmap.php file: 'Portal\\Core\\Bootstrap' => $baseDir . '/src/core/Bootstrap.php', But when I don't run the optimized option on autoload dumping, the autoloading system doesn't works anymore: Fatal error: Class 'Portal\Core\Bootstrap' not found in /var/www/portail/prod/web/index.php on line 7 How can I make autoloading works without -o option? sectus There are two

Slim 3 autoloader

两盒软妹~` 提交于 2019-11-30 04:56:40
问题 I'm new to slim framework, and can't figure out how to use the autoloader to autoload my classes. I created a app/models/myclass.php but of course when I try to use it I get a class not found. I'm not sure which is the right way to autoload classes, or the naming convensions I should use. Should I do it via the composer.json somehow? I'm searching the net for several hours without any solid answer on that. UPDATE : Managed to do it like that: added model in : app/src/Model/Client.php added

Instantiating class by string using PHP 5.3 namespaces

微笑、不失礼 提交于 2019-11-29 23:40:43
I can't get around an issue instantiating a new class by using a string variable and PHP 5.3. namespaces. For example, this works; $class = 'Reflection'; $object = new $class(); However, this does not; $class = '\Application\Log\MyClass'; $object = new $class(); A fatal error gets thrown stating the class cannot be found. However it obviously can be instantiated if using the FQN i.e.; $object = new \Application\Log\MyClass; I've found this to be aparrent on PHP 5.3.2-1 but not not in later versions. Is there a work around for this? $class = 'Application\Log\MyClass'; $object = new $class();

PSR-4 autoloading with Composer

我怕爱的太早我们不能终老 提交于 2019-11-29 11:54:53
问题 I run a portail with composer's autoloading class system: "autoload": { "psr-4": { "Portal\\": "src/" } } It works when I run composer.phar dump -o , for instance my class Boostrap is well referenced into vendor/composer/autoload_classmap.php file: 'Portal\\Core\\Bootstrap' => $baseDir . '/src/core/Bootstrap.php', But when I don't run the optimized option on autoload dumping, the autoloading system doesn't works anymore: Fatal error: Class 'Portal\Core\Bootstrap' not found in /var/www/portail

PSR4 auto load without composer

柔情痞子 提交于 2019-11-29 07:59:23
I have one package in a project which is autoloaded using composer and composer.json entry is as follows : "autoload": { "psr-4": { "CompanyName\\PackageName\\": "packages/package-folder/src/" } } Now I am copying this over to another project which is not using composer. How can I autoload this same package there ? You have to read the composer and load the classes yourself for each namespaces defined into the composer.json . Here is how : function loadPackage($dir) { $composer = json_decode(file_get_contents("$dir/composer.json"), 1); $namespaces = $composer['autoload']['psr-4']; // Foreach

Composer classmap autoload does not load new files in folder

℡╲_俬逩灬. 提交于 2019-11-29 01:15:41
The following problem: I have defined a classmap in my composer.json: "autoload": { "classmap": [ "app/controllers", "app/models", "app/helper.php" ] } However, when I create a new file in the "controllers" or "models" folder, it will not load them and I always have to make a composer dump-autoload. Is this the correct behavior? I thought the autoloader from composer monitors the folder for new files then? Yes, this is correct behaviour. If you want new classes to be loaded automatically, you have to use either PSR-0 or PSR-4 autoloading. Generating the classmap requires Composer to know the