Questions tagged [psr-4]

PSR-4 describes requirements that must be adhered to for autoloader interoperability in PHP. PSR-4 is an alternative to PSR-0 that corrects problems discovered in real-world use.

Specification link:

Code and test samples:

308 questions
0
votes
1 answer

Behat 3 + Symfony 3 Context with namespace doesn't work, when without works

I have the following catalogs structure: composer.json behat.yml src |--AppBundle |--Features |--example.feature |--Context |--FeatureContext.php And the following behat.yml default: autoload: '':…
Daniel
  • 7,684
  • 7
  • 52
  • 76
0
votes
1 answer

Docker php with composer PSR-4

Im trying to publish my webpage using docker on my nas. But Can't get the PSR-4 to work, it wont find the controllers through the namespacing. Everything worked on my vagrant box. But as long as I don't extend a class it wont break Whoops \…
Rasmus Rajje Josefsson
  • 1,564
  • 2
  • 15
  • 33
0
votes
1 answer

Laravel 5.3 how to add psr-4

Error Class 'Mylib\Mytest' not found My routes/web.php Route::get('/', function () { $rs = new Mylib\Mytest; //@FIXME:Del or comment this debug script in routes/web.php dd($rs); //return view('welcome'); }); composer.json "autoload":…
0
votes
1 answer

PSR4 Composer Autoloading namespaces

I've been having a little play around with some Composer autoloading and i'm getting some issues so the directory structure is index.php app/ helpers/ router.php vendor/ composer/ /*usual files*/ autoload.php Inside my…
Matt Stephens
  • 922
  • 1
  • 6
  • 24
0
votes
1 answer

How to autoload classes using PSR-4?

I am trying to set up a device detection system in my php script using device-detector. I am following its documentation to set it up but getting errors while doing that. I have downloaded the required files using composer. I even cloned the repo to…
Ayan
  • 2,738
  • 3
  • 35
  • 76
0
votes
1 answer

"Class HelloController not found" error on composer autoload config with psr4

I try to create my own composer library. I've chose to use psr4 for autoloading mechanism. It works fine with the library project but something goes wrong when I add this library to another project as dependency. I expect the library project create…
brnogz
  • 1
  • 3
0
votes
1 answer

PHP Class, Scope, and Static Variable Clarification needed

I have run into an interesting problem with using static variables in classes and accessing them. In this example I am using PSR-4 loading. At the top of my file I have the usual use Networks\ConfigHandlers\ServicesConfig followed by class…
SeaFuzz
  • 1,177
  • 9
  • 28
0
votes
1 answer

Fatal Error while Importing Class/Interface from the Same Namespace

I have a Duck Interface (abstract class in this case) and Class MallardDuck is implementing it. I'm trying to autoload files from the Duck name space but gets a fatal error. PHP Fatal error: Interface 'Duck\Duck' not found in…
Khuram
  • 1,820
  • 1
  • 26
  • 33
0
votes
0 answers

psr-4 class not found

I'm trying to setup my first project with psr-4 but I receive the following error: Fatal error: Uncaught Error: Class 'leaseregistratie\Repositories' not found in /home/vagrant/Code/testomgeving/index.php:7 Stack trace: 0 {main} thrown in…
Jamie
  • 10,302
  • 32
  • 103
  • 186
0
votes
0 answers

composer PSR4 autoloading issue

I am trying to implement PSR-4 autoloading in my project. It is an existing application I have inherited that doesn't currently use OOP (it's all scripted), but I am hoping to refactor over time to use OOP, and PSR-4 is crucial for me as it will…
Morrolan
  • 77
  • 2
  • 9
0
votes
2 answers

issues when autoloading files with psr-4

I've been trying to get psr-4 autoloading work for over a week now with no success. My file structure is as follows: -Project -src -classes session.php -vendor index.php I've created the psr-4 autoload function as follows: …
Juakali92
  • 1,155
  • 8
  • 20
0
votes
1 answer

composer autoload psr-4 not working

I'm using psr-4 to autoload and create a namespace. But I'm getting this error: Fatal error: Class 'Models\User' not found in /app/routes/users.php on line 7 My architecture app ---routes ------users.php ---VDB ------Models ---------User.php This…
Viktor De Bock
  • 139
  • 1
  • 2
  • 17
0
votes
1 answer

Sublime 3 PSR4 Plugin

Is there a plugin for Sublime 3 to automatically do PSR4 configuration? I am working with a third-party library that's quite old now and needs PSR updating. I've heard you can do something like this using PHPStorm
mikelovelyuk
  • 4,042
  • 9
  • 49
  • 95
0
votes
1 answer

js components autoload psr4

My Composer.json's autoload section as follows "autoload": { "psr-4": { "Xx\\Cloud\\Jquery\\": "/src/components/jquery/jquery.min.js", "Xx\\Cloud\\Angular\\": "/src/components/angular.js/angular.min.js", …
underscore
  • 6,495
  • 6
  • 39
  • 78
0
votes
1 answer

psr4 changes after upgrade have class not found symfony 2,4 -> 2,8

I use "symfony/symfony": "~2.4", and configuration "autoload": { "psr-0": { "": "src/", "Mea":"vendor/", "mea":"vendor/Mea/CoreBundle/", "Place":"vendor/Mea/" } }, i create new project with "symfony/symfony": "2.8.x-dev", first i…
Developer
  • 2,731
  • 2
  • 41
  • 71