Skip to content

YoussefACHCHIRAJ/sefra-plugin-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sefra WordPress Plugin Starter Kit

A modern WordPress plugin starter kit built around OOP, PSR-4 autoloading, and a dependency injection container.

Designed for developers who want maintainable, testable, scalable plugins instead of procedural spaghetti.


Requirements

  • PHP ≥ 7.4
  • WordPress ≥ 5.8
  • Composer

Documentation

Full documentation is available here:

👉 achchiraj.dev/plugins/sefra-starter

Installation

git clone https://github.com/YoussefACHCHIRAJ/sefra-plugin-starter
cd sefra-plugin-starter
composer install

For production plugins, change the default App\ namespace to a unique vendor/plugin namespace to avoid conflicts.

Basic Usage

Plugin Entry File

<?php
/**
 * Plugin Name: Sefra Plugin Starter
 * Description: A starter plugin for WordPress developers.
 * Version: 1.0.0
 * 
 * @package plugin-starter
 */

if (!defined('ABSPATH')) {
    exit;
}

use App\Providers\PluginServiceProvider;
use App\Plugin;
use Sefra\Container;
use Sefra\Providers\App;

require __DIR__ . '/vendor/autoload.php';

App::registerProviders([
    PluginServiceProvider::class,
]);

Container::getInstance()
    ->get(Plugin::class)
    ->boot();

Service Provider

<?php

namespace App\Providers;

use Sefra\Container;
use Sefra\Providers\ServiceProvider;
use App\Services\Logger;
use App\Contracts\LoggerInterface;

class PluginServiceProvider implements ServiceProvider
{
    public function register(Container $container): void
    {
        $container->singleton(
            LoggerInterface::class,
            Logger::class
        );
    }

    public function boot(Container $container): void
    {
        // Register hooks, listeners, side effects
    }
}

Automatic dependencies injection

class UserService
{
    public function __construct(
        LoggerInterface $logger
    ) {}
}

No manual instantiation. Dependencies are resolved automatically.

About

wordpress plugin starter with a service container and auto resolver

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages