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

Warmup lazy services #5

Closed
weierophinney opened this issue Dec 31, 2019 · 7 comments
Closed

Warmup lazy services #5

weierophinney opened this issue Dec 31, 2019 · 7 comments

Comments

@weierophinney
Copy link
Member

Hi there!

I would like to generate all proxies before app deployment (like doctrine has orm:generate-proxies). Some host services (like Heroku) require to do this during "compile" process. Sure, generate on-demain works, but there is many cases when cache is purge.


Originally posted by @snapshotpl at zendframework/zend-servicemanager#278

@weierophinney
Copy link
Member Author

This is only currently possible by running through the instantiation of all services once, in a warmup script.


Originally posted by @Ocramius at zendframework/zend-servicemanager#278 (comment)

@weierophinney
Copy link
Member Author

So I need to write this script or it exists somewhere?


Originally posted by @snapshotpl at zendframework/zend-servicemanager#278 (comment)

@weierophinney
Copy link
Member Author

You'll need to write a script, yup.

I think its contents would be something like array_walk([$serviceManager, 'get'], $serviceManager->getDefinedServices()) or similar

On Thu, 14 Feb 2019, 09:55 Witold Wasiczko <notifications@github.com wrote:

So I need to write this script or it exists somewhere?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
zendframework/zend-servicemanager#278 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakJdt0x1GZA58nvHJgPTLHbTvdJoWks5vNSSSgaJpZM4a7FkL
.


Originally posted by @Ocramius at zendframework/zend-servicemanager#278 (comment)

@weierophinney
Copy link
Member Author

Or:

    public function warmup(): void
    {
        foreach ($this->services as $service) {
            $this->container->get($service);
        }
    }

where services is lazy_services.class_map keys.

Anyway ready script in package will be nice addon


Originally posted by @snapshotpl at zendframework/zend-servicemanager#278 (comment)

@weierophinney
Copy link
Member Author

Don't think we should expand the API for an edge case, and adding a script
also requires knowing which instance of the ServiceManager you are
referring to.

In a zendframework/zend-mvc context, that may be any of the plugin
containers, for example.

On Thu, 14 Feb 2019, 10:06 Witold Wasiczko <notifications@github.com wrote:

Or:

public function warmup(): void    {        foreach ($this->services as $service) {            $this->container->get($service);        }    }

where services' is lazy_services.class_map` keys.

Anyway ready script in package will be nice addon


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
zendframework/zend-servicemanager#278 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakCtLHTLTFvUbctEJEk7djF75cLz_ks5vNSb7gaJpZM4a7FkL
.


Originally posted by @Ocramius at zendframework/zend-servicemanager#278 (comment)

@weierophinney
Copy link
Member Author

Or zf module ;)


Originally posted by @snapshotpl at zendframework/zend-servicemanager#278 (comment)

@GeeH
Copy link
Contributor

GeeH commented Jun 5, 2020

Closing, I feel this was solved in the original issue.

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

No branches or pull requests

2 participants