But as a plus info, that line would create a new instance of the DI, so if you have a global DI created elsewhere with already attached services, you cannot access them with that particular $di variable in your code.

BUT! If you use the static method $di = $di ?: \Phalcon\Di\FactoryDefault::getDefault();, that will return the first DI instance that you've created in your code flow (or any DI you've set as default last).

But as a plus info, that line would create a new instance of the DI, so if you have a global DI created elsewhere with already attached services, you cannot access them with that particular $di variable in your code.

BUT! If you use the static method $di = $di ?: \Phalcon\Di\FactoryDefault::getDefault();, that will return the first DI instance that you've created in your code flow (or any DI you've set as default last).