Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip autoloader generation during install and update #3453

Merged
merged 4 commits into from
Dec 29, 2014
Merged

Skip autoloader generation during install and update #3453

merged 4 commits into from
Dec 29, 2014

Conversation

mattsah
Copy link
Contributor

@mattsah mattsah commented Nov 21, 2014

Added no-autoloader option for install and update which skips the autoloder generation. This has been requested by multiple users and is useful for deployment situations where one might be running composer in two stages.

See: #1663

@Seldaek Seldaek merged commit 14fe882 into composer:master Dec 29, 2014
Seldaek added a commit that referenced this pull request Dec 29, 2014
@Seldaek
Copy link
Member

Seldaek commented Dec 29, 2014

Thanks and sorry for the delay.

@nifr
Copy link

nifr commented Jan 7, 2015

awesome, thanks Jordi 👍

@Jany-M
Copy link

Jany-M commented Aug 22, 2018

Is there any way this could be integrated on a per library basis, in composer.json?

eg.

"require-dev": {
       "dontneed/autoloader": {
             "version": "1.2.3",
            "autoloader": false
       }
}

@stof
Copy link
Contributor

stof commented Aug 23, 2018

@Jany-M this does not make sense, as there is a single generated autoloader, not one per library

@mvl22
Copy link

mvl22 commented Apr 16, 2024

Is there any equivalent of the CLI no-autoloader as a directive within composer.json itself, so that the package itself defines that an autoload.php file should not be dumped? I can't see one.

(I would have thought it should be the package maintainer who determines whether their package uses autoloading, rather than the deployment.)

@Seldaek
Copy link
Member

Seldaek commented Apr 16, 2024

@mvl22 that flag's point is that you can run the dump-autoload at a later step because $reasons, but the point is not to have no autoloader at all, because IMO not using the Composer autoloader for the dependencies is kinda nonsensical overhead.

So no there is no config to persist that..

@mvl22
Copy link

mvl22 commented Apr 18, 2024

not using the Composer autoloader for the dependencies is kinda nonsensical overhead

I'm thinking of the scenario where you have a CMS that has its own autoloader definition, but there are embedded applications within the site that use Composer. In this scenario, you don't want the CMS to have an autoload.php file generated because that will take precedence if an include_path has been set in the VirtualHost. Maybe this too specific a scenario for generic support ;)

I suppose the nearest achievable is to use this hook:

    "scripts": {
        "post-autoload-dump": [
            "rm vendor/autoload.php",
            "rm -rf vendor/composer/"
        ]
    }

@Seldaek
Copy link
Member

Seldaek commented Apr 18, 2024

rm -rf vendor/composer is a bad idea™️. This contains installed.json which will make any further composer install go poorly if you wipe it. It may also contain packages from the composer vendor which would go even worse if they're needed.

If you really must delete files then delete vendor/composer/autoload_*.php and vendor/composer/ClassLoader.php, but really I don't see why you'd need to do that. Just don't include the vendor/autoload.php if you don't want to use it.

And include_path shenanigans yeahhh I wish that was not used anymore.. but I guess it still is :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants