cakephp / plugin-installer

A composer installer for installing CakePHP plugins.
Other
32 stars 18 forks source link

Retreive local plugin's namespace from root pacakage's autload config #35

Closed bouland closed 5 years ago

bouland commented 7 years ago

What do you thinks about this feature ? Will add tests if yes.

    "autoload": {
        "psr-4": {
            "MyNameSpace\\": "src",
            "MyNameSpace\\MyPlugin\\": "./plugins/MyPlugin/src"
        }
    },

Will generate vendor/cakephp-plugins.php

<?php
$baseDir = dirname(dirname(__FILE__));
return [
    'plugins' => [
        'Bake' => $baseDir . '/vendor/cakephp/bake/',
        'DebugKit' => $baseDir . '/vendor/cakephp/debug_kit/',
        'Duplicatable' => $baseDir . '/vendor/riesenia/cakephp-duplicatable/',
        'MyNameSpace/MyPlugin' => $baseDir . '/plugins/MyPlugin/',
        'Josegonzalez/Version' => $baseDir . '/vendor/josegonzalez/cakephp-version/',
        'Migrations' => $baseDir . '/vendor/cakephp/migrations/'
    ]
];
ADmad commented 7 years ago

Why? What are you trying to achieve with this?

bouland commented 7 years ago

In short : Namespace purpose is to deal with naming conflict, actual local plugin namespace is to strong, need to release this. Long story : When I write a new plugin I don't know if it will be shared afterword. I start coding in local plugin/ but next if i published it under its own repo I need to rewrite all namespace and use statements for avoiding any colision with other community, could not publish with single generic word aka Duplicatable, Import, Export Josegonzalez/Version is good exemple

elboletaire commented 6 years ago

@bouland why not properly set the namespaces from the beginning? I mean... I always use Cirici\ as a prefix on my namespaces (or Alvarium\, depending on the company for which I develop the plugin), whether it's an internal plugin, or an external one (installed using composer in vendor).

It's a bit more of work, but then the plugins work always in all conditions.

ADmad commented 5 years ago

As mentioned in above comment just prefix the namespace before hand to avoid future collisions.