0
votes

So...I have a weird one. I have a composer.json file formatted like this:

{
    "require": {
        "twilio/sdk": "^6.20"
    },
    "autoload": {
        "classmap": [
            "model/*"
        ]
    }
}

And I am trying to deploy a PHP application with that composer.json to an App Engine app service. But, when Cloud Build runs composer install --no-dev --no-progress --no-suggest --no-interaction while building the application, Composer throws this error:

Step #6 - "builder": 
Step #6 - "builder":                                                                                                  
Step #6 - "builder":   [RuntimeException]                                                                             
Step #6 - "builder":   Could not scan for classes inside "model/*" which does not appear to be a file nor a folder  
Step #6 - "builder":                                                                                                  
Step #6 - "builder": 

The problem is, when I run that exact command in the directory App Engine is building, I generate the autoload classes fine.

There is one class recursively in the model folder right now.

Also, when I remove the autoload section from the composer.json, it deploys to app engine just fine, and I have verified the existence of the directory in the deployed app files.

So my question is:

Why is Cloud Build getting a composer error that I can't reproduce locally?

---- EDIT ----

My file structure looks like this: File structure for this project

File Structure again

2
How does your project file structure looks like? - rob006
@rob006 added above - Adam McGurk

2 Answers

2
votes

Wildcard is supported in classmap path since Composer 2.0. I assume that during build Composer 1.x is used, and it does not recognize this syntax.

I suggest to just remove asterisk from path, since the meaning is exactly the same and it works on older Composer too.

"autoload": {
    "classmap": [
        "model/"
    ]
}
0
votes

In most of cases it is happen because of copy or cloning and you have some corrupted files or any composer update has crashed or interrupted.

So, just delete the vendor folders and install again

composer clearcache && rm -rf vendor && composer install

Also, he problem with classmap is that you need to regenerate the classmap array every time you create a new class file eventhough Classmap autoloading is the fastest among autoloaders since it loads classes from the prebuilt array.