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
1
vote
0 answers

psr-4 autoload not working on namecheap.com live server

I am using namecheap to host my website. I used psr-4 autoload and its working fine on my local computer but not on a live server. I have contatcted the customer support and followed all the instructions here…
1
vote
0 answers

how to load Normal files using composer autoloader

How to load normal files using composer actually psr-4 loader classes along with namespaces I know but if we have normal files inside that function for example if have functions and arrays so how can access arrays from that file like this
1
vote
1 answer

Checking if defined VS PSR-4 class autoload. Why in PSR-4 autoload need no "system" contant definition?

In CMS or any known php systems the following practice is followed: In a "main php" file a constant is declared for example in moodle is defined such as MOODLE_INTERNAL and in order to use the database the docs suggest the following (as seen in this…
Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164
1
vote
0 answers

How to use logger without composer and namespaces?

I am trying to install Mangopay https://github.com/Mangopay/mangopay2-php-sdk, but the recommended solution of installing it without composer doesn't work. I used this line: require_once "mango/mangopay2-php-sdk-2.11.0/MangoPay/Autoloader.php"; $api…
dfhdfh
  • 35
  • 1
  • 6
1
vote
1 answer

Why I needed to recreate the composer autoloader inside the Homestead VM via ssh?

My project has the following file structure: |- src |-- PcMagas |---- Dropbox.php |---- DropBoxFactory.php |- web |-- index.php And anything in the src folder is getting autoloaded as PSR-4 dictates via composer: "autoload": { "psr-4":{ …
Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164
1
vote
3 answers

Fatal error: Uncaught Error: Class 'App\Config' not found

I have build a custom MVC Framework. Local its working fine, when I try to get it working on a live shared hosting server I will get this error: Error Message in Browser: Fatal error: Uncaught Error: Class 'App\Config' not found in…
user3576592
1
vote
1 answer

PRS-4 - Why does Class 'App\\TgHelpers\\TelegramCommandsProcess' not found?

The structure of my project is as follows: Handler.php is input script. Here is its beginning: require "vendor/autoload.php"; use \App\TgHelpers\TelegramCommandsProcess; $tgProcessor = new TelegramCommandsProcess(); All scripts are in the same…
Bipa
  • 271
  • 1
  • 3
  • 10
1
vote
2 answers

Namespaced classes not found

In Symfony4 projects, I'd like to autoload classes defined in the src folder but whose namespace does not start with App. Let's say it starts with Acme instead. I was expecting that the following configuration in composer.json to work, but it…
David
  • 2,603
  • 4
  • 18
  • 28
1
vote
1 answer

What's the point of the difference between the implement of composer PSR-4 autoload and the example in PSR-4 document

This is the implementation of composer PSR-4 autoload: private function findFileWithExtension($class, $ext) { // PSR-4 lookup $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; $first = $class[0]; if…
1
vote
1 answer

Class not found in psr-4 composer autoloading

I have a base folder with a vendor folder which include composer folder and my created folder src. The src folder contain all classes required to work. In src folder, I have class example below
1
vote
1 answer

Can't load class on Slim 3

I'm trying to load my custom classes for the model on Slim 3 (using the skeleton) so I made this: In app/composer.json: "autoload": { "psr-4": { "App\\Classes\\": "/src/classes" } }, In routes.php I have this setting:
ffuentes
  • 1,042
  • 5
  • 16
  • 36
1
vote
1 answer

PHP: PSR-4 class not found?

Class 'LoginController' not found, I load all my Controllers using PSR-4 autoloading. "autoload": { "psr-4": { "App\\": "app/" } } In here, when ever I need to call methods on controllers I simply find the class, create a new…
guziba
  • 21
  • 3
1
vote
0 answers

PSR-4 Autoloading in Laravel

Working on an application that will be used to extend the Chatter package Issue is, I want to make modifications to the package but don't want to do is directly to the package. Changes won't persist after a composer update. Now from my understanding…
sogeniusio
  • 111
  • 3
  • 14
1
vote
1 answer

PSR-4 Autoloader not recognizing classes in subfolder structure

I am using Slim PHP as the underlaying framework for my app and composer autoload for the loading of my classes. In composer i have this psr-4 configuration: "psr-4": { "App\\": "app/classes/" } All my classes are in /app/classes/…
jhon dano
  • 660
  • 6
  • 23
1
vote
1 answer

Why using PSR4 autoload doesn't add any classes into classmap/namespaces file?

I've got the following composer.json file: { "require-dev": { "queueit/KnownUser.V3.PHP": "dev-master" }, "repositories": [ { "type": "package", "package": { "name": "queueit/KnownUser.V3.PHP", "version":…
kenorb
  • 155,785
  • 88
  • 678
  • 743