maximebf / atomik

Micro framework for PHP 5.3+ [UNMAINTAINED]
MIT License
46 stars 18 forks source link

Controller plugin seems not working. #5

Closed rippak closed 11 years ago

rippak commented 11 years ago

I've created:

/app/actions/archve.php with ArchiveController in it. With action index() { $this->var = "var";} /app/views/archive/index.phtml with <?echo $var?>

added route in config to call controller added controller plugin.

But atomik uses /app/action/archive.php as action not Controller.

And there is undefined variable messge on page http://examle.com/archive/

maximebf commented 11 years ago

I will check ASAP

rippak commented 11 years ago

Sorry, but this problem is deeper then Controller plugin. All plugins are not starting.

I installed Atomik without composer. So I don't know if this issue presents for composer installation.

Solved it by breaking down app/plugins path in Atomik core file.

@@ -2265,7 +2265,7 @@
         /* @var array */
         'dirs' => array(
             'public'             => '.',
-            'plugins'            => array('Atomik' => __DIR__ . '/plugins', 'app/plugins'),
+            'plugins'            => array('Atomik' => __DIR__ . '/plugins', '1app/plugins'),
             'actions'            => 'app/actions',
             'views'              => 'app/views',
             'layouts'            => array('app/views', 'app/layouts'),

After that params for class_exists in Atomik.php:1517 become "Atomik\Db" instead of "Db".

maximebf commented 11 years ago

Ok the problem is with the path inside the dirs array. All plugins bundled with atomik belong to the Atomik namespace. So if you add the bundled plugins inside the app/plugins without specifying the namespace, this will cause a problem because Atomik will think those plugins belong to the root namespace.

The solution is to put the plugins bundled with Atomik inside the app/plugins/Atomik folder. Another solution is to create a different plugin dir for bundled plugin. Example: Atomik::add('atomik/dirs/plugins', array('Atomik' => 'app/bundledplugins')

maximebf commented 11 years ago

there was also an actual bug with the controller plugin which is now fixed