1. Go to this page and download the library: Download bmd/wp-framework 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/ */
bmd / wp-framework example snippets
namespace Acme\Plugin;
use Bmd\WPFramework\Main;
final class App extends Main
{
public const PACKAGE = 'acme_plugin';
}
( new App(
[
'config.dir' => __DIR__,
'config.url' => plugin_dir_url( __FILE__ ),
]
) )->mount();
namespace Acme\Plugin\Controllers;
use Bmd\WPFramework\Abstracts\Controller;
final class NoticesController extends Controller
{
public function mountActions(): void
{
add_action( 'admin_notices', [ $this, 'renderNotice' ] );
}
public function renderNotice(): void
{
// Render your notice.
}
}
namespace Acme\Plugin;
use Acme\Plugin\Controllers\NoticesController;
use Acme\Plugin\Services\ApiClient;
use Bmd\WPFramework\Main;
use Bmd\WPFramework\Services\ServiceLocator;
final class App extends Main
{
public const PACKAGE = 'acme_plugin';
public static function getServiceDefinitions(): array
{
return array_merge(
parent::getServiceDefinitions(),
[
ApiClient::class => ServiceLocator::autowire(),
NoticesController::class => ServiceLocator::autowire(),
]
);
}
}
namespace Acme\Plugin\Services;
use Bmd\WPFramework\Services\FilePathResolver;
use Bmd\WPFramework\Services\UrlResolver;
final class Manifest
{
public function __construct(
private FilePathResolver $paths,
private UrlResolver $urls
) {}
public function path(): string
{
return $this->paths->resolve( 'build/manifest.json' );
}
public function url(): string
{
return $this->urls->resolve( 'build/manifest.json' );
}
}
text
build/frontend.js
build/frontend.asset.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.