Reputation: 5271
I'm developing classes in PHP. For naming I followed the PSR-4 Autoloader rules:
https://www.php-fig.org/psr/psr-4/
But somehow I'm confused. So for example if I have this class in the following structure, how should I define the namespace?
The path of the file:
wmx/includes/classes/admin/Wmx_Settings.php
The class name:
class Wmx_Settings {....
My thoughts about namespaces:
namespace Johnny\Wmx\Admin\;
namespace Johnny\Wmx\Admin\Wmx_Settings;
So how should I define my namespaces now? I'm not very clear about that. Thanks for your help!
Upvotes: 0
Views: 145
Reputation: 1
namespace MyNamespaceName;
require 'project/database/connection.php';
use Project\Database\Connection as Connection;
$connection = new Connection();
use Project\Database as Database;
$connection = new Database\Connection();
Upvotes: -1