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
3
votes
2 answers

Which version of PSR is valid?

Maybe I don't understand fully. I read that PSR is PHP Standard Recommendation, but there are several version of PSR, For Example autoloader use PSR-4 instead Basic Coding Standard use PSR-1 I have to follow a specific PSR version Or I have to…
monkeyUser
  • 4,301
  • 7
  • 46
  • 95
3
votes
2 answers

codeigniter 3 namespacing issue

I am working on codeigniter 3. I use composer psr-4 autoload. I enable composer config as $config['composer_autoload'] = FCPATH."vendor/autoload.php"; and my composer.json autoload as "autoload":{ "psr-4":{ "App\\":"application" …
Iftakharul Alam
  • 3,201
  • 4
  • 21
  • 33
3
votes
1 answer

Class Not Found using PSR-4

I have a PSR-4 specification in my composer.json file as below "autoload" : { "psr-4" : { "MyMVC\\" : "app/" } }, Above is my directory structure. In my Core/Config.php file i have class Config that is under namespace MyMVC\Core.…
Raheel
  • 8,716
  • 9
  • 60
  • 102
3
votes
3 answers

namespace defined in autoload psr-4 using in laravel 5 app.php giving not found error

stucked my heads in some errors.i dont getting where i have done my mistake. I am using laravel 5 and installed it.I want to use l5-repository so i installed https://github.com/prettus/l5-repository this repository using composer commnad: composer…
Vishal Patel
  • 1,715
  • 16
  • 26
3
votes
1 answer

Composer classmap and loading files with non-standard extensions

When loading files through the composer classmap functionality is it possible to load PHP files that have non-standard extensions such as myFileName.stub or myFileName.foo ? At present it seems not to be loading them.
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
2
votes
1 answer

How to make Composer/PSR-4 make accepting my second namespace in a subfolder?

Given is a Symfony 4.4 Application (specifically, Sylius) using PSR-4 for autoloading: "autoload": { "psr-4": { "App\\": "src/", "KYCBundle\\": "src/KYCBundle/" } }, Placing all Controllers and…
itinance
  • 11,711
  • 7
  • 58
  • 98
2
votes
0 answers

Deprecation Notice: Class App\Http\Controllers\tagsController does not comply with psr-4 autoloading standard

whenever i try to update my composer, or require a file from composer for my laravel project, i always get this: Deprecation Notice: Class App\Http\Controllers\tagsController located in…
Godwin
  • 31
  • 1
2
votes
2 answers

MVC using composer autoload psr-4 is not worked for me

I'm trying to create a MVC structure and use composer to autoload everything. But I keep getting this error: Fatal error: Uncaught Error: Class 'App\Core\Main' not found in /var/www/html/php-framework/index.php:20 Stack trace: #0…
Vickysw
  • 70
  • 10
2
votes
2 answers

Error: Class 'path' Is not compliant with PSR-4 configuration

I am trying PHP coding standard package: https://github.com/inpsyde/php-coding-standards, but when I start running phpcs, I get: nickan@nickan-VirtualBox:~/src/wordpress/wp-content/plugins/my-plugin$ vendor/bin/phpcs ./src/model/Users.php E 1 / 1…
Nickan
  • 313
  • 2
  • 11
2
votes
0 answers

Make PDO connection available throughout the application while using autoloader PSR-4

How to make PDO instance available throughout entire application in PHP ? I'm using autoload from PS4 allowing to access any class in the application by using : use Namespace\ClassName; In the case the class has static method, I can use this very…
Cephou
  • 257
  • 5
  • 23
2
votes
1 answer

TYPO3 Composer mode PSR-4 not loading classes

I have an extension located under ext/my_ext. My viewhelper is located under /ext/my_agarar_template/Classes/ViewHelpers/TestViewHelper.php. when I try to call my viewhelper, my template says that my class doesn't exist. My template looks like…
lvollmer
  • 1,418
  • 2
  • 13
  • 32
2
votes
2 answers

Pimple ArgumentCountError: Too few arguments to function

I'm trying to understand dependency injection, and I in theory, I get it, but, I wanted to make an example just to help me. However, I'm getting the following error PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function…
Kearney Taaffe
  • 647
  • 8
  • 20
2
votes
1 answer

Slim3 PSR-4 autoloader

I am writing Slim3 API, for some reason slim is not loading namespace defined in composer. Here is the project structure. FolderStruc: projectApi - composer.json - src - public - index.php - ProjectName - Api -…
danyal14
  • 367
  • 1
  • 4
  • 18
2
votes
1 answer

How to generate Doctrine entities From Database and Use PSR-4 Autoloading?

Using Doctrine 2.5 with PSR-4 autoloading and converting an already designed database schema to entity classes (annotations). The problem is getting the exported files in the correct directory structure. composer.json { "autoload": { …
2
votes
1 answer

Composer Autoload.php not loading in Namespaces and Classes on live hosting

I have a simple PHP web app with the following structure: / (composer.json .htaccess ...) /Core/ (Router.php, Controller.php ...) /App/ (/Controllers, /Models, /Views ...) /Public/ (index.php ...) /Vendor/ (autoload.php…
IMO
  • 307
  • 1
  • 3
  • 12