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

Facing issue when use Lusitanian/PHPOAuthLib

I'm new with Composer. I have added the Lusitanian/PHPOAuthLib with Composer and then I created psr-4 autoload directory and I made a class in that named OAuth. I gave namespace which I want but I'm unable to use the PHPOAuthLib with my class,…
0
votes
1 answer

PSR-4 Namespace with Sub Directories

Im having trouble with my Laravel application and PSR-4 autoloading. I read that you can have multiple 'sub directory' structure in namespaces like this... VendorName\ApplicationName\(SubDir)\ClassName Basically I have my user repositories like…
Jimmy Howe
  • 185
  • 1
  • 1
  • 13
0
votes
3 answers

Laravel, namespaces and PSR-4

I'm trying to set up PSR-4 within a new Laravel 4 application, but I'm getting some troubles achieving what I want when it comes to build controllers. Here's what I have now : namespace MyApp\Controllers\Domain; class DomainController extends…
BMN
  • 8,253
  • 14
  • 48
  • 80
0
votes
1 answer

Why is Composer not loading a PSR-4 autoload?

I'm trying to use the composer vimeo package "vimeo/vimeo-api": "dev-master". Things get ugly in composers own ClassLoader.php, in the function below it gets as far as: if (0 === strpos($class, $prefix)) and breaks out of the loop because at this…
Owen
  • 7,347
  • 12
  • 54
  • 73
0
votes
1 answer

Custom autoloader for project vs Composer PSR-4

I'm currently working on a small framework which has the following directory structure: / -- app -- vendor -- framework-vendor -- framework-package -- src Currently what I have in my framework's composer.json are two PSR-4…
rtheunissen
  • 7,347
  • 5
  • 34
  • 65
0
votes
1 answer

psr-4 autoload - cannot redeclare class

I'm trying to use psr-4 autoload for the first time with Laravel. After I do that with models and I have the following eloquent model:
user2094178
  • 9,204
  • 10
  • 41
  • 70
-1
votes
1 answer

How to import and register class from a list of service providers at runtime?

Are you able to solve this problem? help me Procedure There is a folder called 'plugins' in the base path of laravel; Inside that folder there are only subfolders that are the plugins; In the subfolder where the plugin is, there is a single file to…
-1
votes
1 answer

Can we add subdirectory manually after the psr-4 composer namespace path?

I have different versions of files which are stored in separate subfolders inside a main folder. I intend to use subfolder based on a dynamically determined value of $ver. Can I create a psr-4 composer namespace for the main folder and then add to…
Crunch
  • 57
  • 12
-1
votes
1 answer

Composer PSR-4 autoload is not working after trying multiple methods and tutorials

I was making a composer library for functionality of my framework, but I got stuck on this problem, the problem is with autoloading with psr-4. My Configuration I have the following structure ├───src ├───test └───vendor ├───composer …
nullcoder
  • 103
  • 2
  • 11
-1
votes
2 answers

Error: The autoloader expected class ... to be defined in file. inSymfony 3.4

For the update to Symfony 4.0, I added "_default" and "AppBundle" to services.yml and verified the operation, but the following error occurred. I have two bundles and want to achieve automatic wiring for each. Is there anything wrong with…
go_live
  • 29
  • 7
-1
votes
1 answer

Autoloading of classes through composer does not work

I have a project structure: In the index.php I create 2 new objects: use App\Controllers\Test; use Xuborx\Cms\App; new Test(); new App(); My Test.php
-1
votes
2 answers

Composer complains about non-compliance to PSR-4, even though everything seems fine

In my project, I'm including a package I'm developing, which has a composer.json, which includes the following autoload entry: (censored to not get in trouble with my company of course) { "autoload": { "psr-4": { …
Julian
  • 105
  • 1
  • 5
-1
votes
1 answer

How manage annoying Namespace and Class name redundancy on PHP and PSR-4

In many of my PHP micro-library, there are Class matching with project name, it create a strange fully qualified class name, look at this
Francesco Bianco
  • 519
  • 1
  • 5
  • 12
-1
votes
1 answer

Can I use a PHP library file of classes with PSR-4 autoloading, and does it even make logical sense?

I envisage developing an API client library which may use many small utility classes. Do I have to have a separate file for each class if using PSR-4? Is my approach sound, and if so how can I achieve it? Edit in response to answers: I didn't…
Dizzley
  • 487
  • 6
  • 16
-1
votes
1 answer

Composer and PSR-4

I readed much topics, but no noone resolved my problem. In main directory i have composer.json, vendor dir and coredir which has Router.php file Router.php namespace Core; class Router{} composer.sjon "autoload": { "psr-0": { "Core\\":…
Nexicoll
  • 27
  • 6
1 2 3
20
21