On this page you find information about the implemented php standards recommendations in Nextcloud.
This standard has been deprecated and will be removed in Nextcloud 27. Please see the PSR-4 section instead.
PSR-3: Logger Interface
New in version 19.
The dependency injection container can inject an instance of a
\Psr\Log\LoggerInterface. This is merely a wrapper of the existing (and strongly typed)
\OCP\ILogger. Apps may still use the Nextcloud logger, but the PSR-3 implementation shall easy the integration of 3rd party libraries that require the PSR-3 logger.
Changed in version 21: Nextcloud ships version 1.1.3
Changed in version 23: Nextcloud ships version 1.1.4
The PSR-4 standard describes how class files should be named, so Nextcloud can automatically load them. See the classloader docs for details.
PSR-11: Container Interface
New in version 20.
The dependency injection container follows the PSR-11 container interface, so you may type-hint
\Psr\Container\ContainerInterface whenever you want an instance of a container and use
has($id) to check for existence and
get($id) to retrieve an instance of a service. See the dependency injection docs for details.
Changed in version 22: Nextcloud ships version 1.1.1
Changed in version 27: Nextcloud ships version 2.0.2
New in version 27.
\OCP\AppFramework\Utility\ITimeFactory class follows the PSR-20 clock interface, so you may type-hint
\PSR\Clock\ClockInterface and then use the
now() method whenever you want to get the current time. You can also change the timezone for the to be returned
\DateTimeImmutable instance, by getting a new