autoload

Composer, Laravel and local packages

最后都变了- 提交于 2020-07-17 06:47:20
问题 My issue is I have a package which isn't a repository and I am trying to get it to play nice with Laravel and composer. It is still located under the vendor folder, the only issue is that if I simply set: "psr-0": { "Test\\Test": "vendor/test/test/src/" } This will load the service provider but none of the controllers etc will autoload. What is the correct way to implement a package with larval that does not have it's own repository. Or does this go against the nature of packages and this

rails: autoload files inside engine's lib directory

非 Y 不嫁゛ 提交于 2020-06-25 21:34:32
问题 I am working on this rails application with an engine which is sort of sub application adding some more routes to my existing application. The concept is so powerful, thanks to rails. But I am facing this weird challenge to autoload file changes inside my engines lib directory in development mode. Every time I make a change inside app directory of engine be it model or controller , it works flawlessly, but no changes to any files under lib directory get's picked up. Is there a way I can do

rails: autoload files inside engine's lib directory

我的梦境 提交于 2020-06-25 21:33:28
问题 I am working on this rails application with an engine which is sort of sub application adding some more routes to my existing application. The concept is so powerful, thanks to rails. But I am facing this weird challenge to autoload file changes inside my engines lib directory in development mode. Every time I make a change inside app directory of engine be it model or controller , it works flawlessly, but no changes to any files under lib directory get's picked up. Is there a way I can do

rails: autoload files inside engine's lib directory

你离开我真会死。 提交于 2020-06-25 21:33:08
问题 I am working on this rails application with an engine which is sort of sub application adding some more routes to my existing application. The concept is so powerful, thanks to rails. But I am facing this weird challenge to autoload file changes inside my engines lib directory in development mode. Every time I make a change inside app directory of engine be it model or controller , it works flawlessly, but no changes to any files under lib directory get's picked up. Is there a way I can do

Rails 6+, zeitwerk autoloader and namedspaced constants

久未见 提交于 2020-06-16 03:44:26
问题 The Rails 6+ default autoloader is zeitwerk, which seems like a great improvement over previous approaches. However, zeitwork follows the convention for Rails projects that anything in app/* is autoloaded and doesn't need to be namespaced. This works great for app/models/user.rb because you don't have to use Models::User but can just reference User . However, I added my own app/services directory and I namespace my service objects as Services::Users::Create , which would map to app/services

Why should we use composer rather than using include_once or require_once?

假装没事ソ 提交于 2020-04-15 16:10:30
问题 I have searched many blogs and websites but I didn't find any perfect answer. whenever I use composer I have to include the autoload.php file and then for each class to autoload I have to use that class with the namespace.now I want to know what is the advantage of this composer where I can easily include the class file by include_once or require_once rather than using both autoload.php and the class file individually. when I use composer I have to write these code: include_once("vendor

Composer Autoload Multiple Files in Folder

∥☆過路亽.° 提交于 2020-04-08 08:46:44
问题 I'm using composer in my latest project and mapping my function like this "require": { ... }, "require-dev": { ... }, "autoload": { "psr-4": { ... }, "files": [ "src/function/test-function.php" ] } I imagine there will be a lot of files in a folder function, ex : real-function-1.php, real-function-2.php, etc. So, can composer call all the files in the folder function ? i lazy to use "files": [ "src/function/real-function-1.php", "src/function/real-function-2.php", .., "src/function/real

Codeigniter “require(./vendor/autoload.php): failed to open stream” error just if it is run by cronjob - not a composer problem apparently

狂风中的少年 提交于 2020-03-05 03:04:26
问题 This is a consequent question of another one that can be found at Not working shared hosting cPanel cronjob under Codeigniter and it is worth to be asked apart. This is the context: codeigniter framework is used scheduler is defined as a controller and called by a cronjob the web server is a shared hosting managed with cPanel the cronjobs work properly if defined as pure PHP ones outside codeigniter the schedule controller if is called by the browser directly work fine: https:/

PHPUnit autoloading classes

本秂侑毒 提交于 2020-01-25 01:07:28
问题 Question in short How can I make the Autoloader find all classes required to run my PHP tests? Question in detail I want to autoload the classes that I am using in PHPUnit in Eclipse. My directory structure is as follows. Project (called yii-app) protected dirA classA.php dirB classB.php yii-1.1.14.f0fee9 Yii.php tests ClassATest.php ClassBTest.php bootstrap.php Autoloader.php I use the bootstrap.php and Autoloader.php that I found here, see below for details. The Class classA does not make

Why does 'composer dumpautoload -o' fix 'Class not found' PHP error?

别等时光非礼了梦想. 提交于 2020-01-25 00:20:09
问题 I have a Laravel 5.8 project that is dependent on a private package. When I run composer install the package is installed and shows up in the vendor folder. project composer.json { ... "require": { "php": ">=7.0", "company/api-request": ">=1.0.0" } ... } package src/ApiRequest.php <?php namespace Company; class APIRequest { ... } package composer.json { ... "autoload": { "psr-4": { "Company\\": "src/" } } ... } When I call the package \Company\APIRequest::run(); I am getting Message: Class