1. Go to this page and download the library: Download magna-cms/plugin-sdk 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/ */
magna-cms / plugin-sdk example snippets
use Magna\Admin\Nav\NavGroup;
use Magna\Admin\Nav\NavItem;
use Magna\Contracts\RegistersAdminNavigation;
use Magna\Plugins\Plugin;
class BlogPlugin extends Plugin implements RegistersAdminNavigation
{
public function boot(): void
{
$this->loadViewsFrom('resources/views', 'blog');
$this->loadRoutesFrom('routes/web.php', 'web');
}
public function adminNavigation(): NavGroup
{
return NavGroup::make('Blog', 'book-open')->items([
NavItem::page('Posts', 'filament.admin.resources.blog-posts.index')
->can('blog.posts.view'),
]);
}
}
use Magna\Testing\PluginTestCase;
final class BlogPluginTest extends PluginTestCase
{
protected string $plugin = 'acme/blog';
public function test_it_boots_with_routes_and_permissions(): void
{
$this->assertPluginEnabled('acme/blog');
$this->assertRouteRegistered('api/v1/blog/posts');
$this->assertPermissionRegistered('blog.posts.view');
}
}
bash
php artisan magna:plugin:make acme/blog
bash
php artisan magna:plugin:enable acme/blog
json
{
"name": "acme/blog",
"displayName": "Blog",
"description": "A simple blog for Magna.",
"version": "1.0.0",
"author": "Acme",
"license": "MIT",
"compat": { "magna": "^1.0", "php": "^8.3" },
"entry": "Acme\\Blog\\BlogPlugin",
"permissions": ["blog.posts.view"],
"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.