1. Go to this page and download the library: Download dneustadt/majima library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dneustadt / majima example snippets
namespace Plugins\MyPlugin;
class MyPlugin extends PluginAbstract
{
private $priority = 0;
private $version = '1.0.0';
public function getPriority()
{
return $this->priority;
}
public function getVersion()
{
return $this->version;
}
public function update()
{
}
public function install()
{
}
public function build()
{
}
public function registerControllers()
{
return new ControllerCollection([
'my_plugin.my_controller' => MyController::class,
'majima.admin_controller' => AdminControllerDecorator::class,
]);
}
public function setRoutes()
{
$routeCollection = new RouteCollection();
$routeCollection->addRoute(
new RouteConfig(
'myPlugin_index',
'/hello/world/',
'my_plugin.my_controller:indexAction'
)
);
$routeCollection->addRoute(
new RouteConfig(
'admin_new',
'/admin/new/',
'my_plugin.majima.admin_controller:newAction'
)
);
return $routeCollection;
}
public function setViewResources()
{
$viewCollection = new ViewCollection(join(DIRECTORY_SEPARATOR, [__DIR__, 'Resources']));
$viewCollection->setViews(['views']);
return $viewCollection;
}
public function setCssResources()
{
$assetCollection = new AssetCollection(join(DIRECTORY_SEPARATOR, [__DIR__, 'Resources', 'css', 'src']));
$assetCollection->setFrontendAssets([
join(DIRECTORY_SEPARATOR, ['frontend', 'all.scss']),
]);
$assetCollection->setBackendAssets([
join(DIRECTORY_SEPARATOR, ['backend', 'all.scss']),
]);
return $assetCollection;
}
public function setJsResources()
{
$assetCollection = new AssetCollection(join(DIRECTORY_SEPARATOR, [__DIR__, 'Resources', 'js', 'src']));
$assetCollection->setFrontendAssets([
join(DIRECTORY_SEPARATOR, ['frontend', 'jquery.js']),
]);
$assetCollection->setBackendAssets([
join(DIRECTORY_SEPARATOR, ['backend', 'jquery.plugin.js']),
]);
return $assetCollection;
}
}
class MyController extends MajimaController
{
/**
* @param Request $request
*/
public function indexAction(Request $request)
{
$bar = $this->dbal->from('foo')->fetchAll();
$this->assign(
[
'foo' => $bar,
]
);
}
}
// returns Response with rendered content
return $this->engine->render('/path/to/my/template.tpl');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.