1

I'm creating a composer package but my library uses a ".class.php" extension instead of the usual ".php" extension.

E.g. BaseController.class.php for BaseController class

As a result of this the Composer Autoloader is unable to find my files.

How do I fix this?

5
  • You could use always classmap, but you need to regenerate it after each class addding. Commented Dec 22, 2014 at 9:54
  • ok, I just looked into that and there are at least 50+ .class.php files inside my library. Is it recommended that I do this or should I just fork my library and rename all .class.php and .php and use that? Commented Dec 22, 2014 at 9:59
  • See ClassLoader.php inside composer folder. If I change this line to use '.class.php' it works! >> $file = $this->findFileWithExtension($class, '.php'); //line 303 Commented Dec 22, 2014 at 10:04
  • Then use it as accepted answer Commented Dec 22, 2014 at 15:08
  • I wish I could but composer overwrites ClassLoader.php when I run it. Commented Dec 22, 2014 at 15:13

1 Answer 1

1

After a lot of research there are two ways of doing it. Unfortunately neither is good enough but for now anyone who faces this problem can use it:

  1. Rename all .class.php to .php if it is your own library
  2. In line 303 of ClassLoader.php (inside composer folder) change .php to .class.php

$file = $this->findFileWithExtension($class, '.php'); //line 303 $file = $this->findFileWithExtension($class, '.class.php'); //line 303

Hopefully there will be support for this in future versions!

Sign up to request clarification or add additional context in comments.

1 Comment

Step 1 is the only correct course of action. Using class.php as an extension serves no purpose other than to make your code look outdated and antiquated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.