Is it necessary to use namespaces as per PHP's PSR-1 coding standard?

55 Views Asked by At

I am new to following the coding standard PSR for PHP, specifically conforming to PSR-1 and PSR-12. Now I am confused about one thing.

That is, is it necessary to use namespaces as per the PSR-1 standard? There's no explicit mention of the fact that it's a MUST to use them.

Also, let's suppose I have the following code in a single file:

<?php

class A
{}

class B extends A
{}

class C extends A
{}

Based on the PSR-1 standard (and its mention of namespaces and classes), is this code OK, or do I have to create a separate file for each class, along with a separate namespace for each file?

0

There are 0 best solutions below