TypeRocket Is the Complete WordPress MVC Framework

WordPress is a nightmare for modern developers; especially after coding Laravel, Rails, or Django. TypeRocket is the complete MVC framework for WordPress that makes modern developers feel at home.

Make Anything Fast

Need a custom API for your headless project? Need a SPA? Build it fast and with less code using TypeRocket.

MVC Anywhere

Enjoy the MVC design pattern anywhere in WordPress. Frontend or backend.

Routes & Middleware

Add routes and middleware to your project without fighting WordPress rewrite rules by using an elegant Laravel like syntax.

MVC-Up Your Theme

DRY up your theme's templates using TypeRocket Pro's MVC template routing system.

MVC Backends

Create powerful MVC backends with a minimal fluent syntax crafted for professional developers.

What is MVC like in WordPress?

It is a professional developer's dream world.

(new Page)->whereMeta('featured', 'yes')->get();
(new Post)->published()->with(['meta', 'author.meta'])->paginate();
(new Page)->published()->find()->load(['meta', 'author.meta']);
(new User)->with(['meta'])->get();
// View: blog.single
$this->layout('layouts.blog');

if($posts) : 
foreach($posts as $post) :
    echo '<h1>' . $post->title() . '</h1>';
    echo $post->content();
endwhile;
endif;
// View: layouts.blog
$this->header('parts.header');

$this->yield('main');

$this->footer('parts.footer');
tr_route()->get()->on('my-api/posts/*', 'post@ApiController');
class ApiController extends Controller  
{
    function posts(Post $post, Response $response) {
        if($post->can('read')) {
            return $post->load(['meta', 'author.meta'])->paginate();
        }

        return $response->unauthorized('No so fast!');
    }
}
class PostPolicy extends Policy
{
    public function update(AuthUser $auth, WPPost $post)
    {
        if( $auth->isCapable('edit_posts') || $auth->getID() == $post->getUserID()) {
            return true;
        }

        return false;
    }
}
class CanEditUsers extends Middleware {
    public function handle() {

        if( ! $this->handler->getHook() && ! current_user_can( 'edit_users' ) ) {
            tr_abort(401);
        }

        $this->next->handle();
    }
}
// wp-content/themes/my-theme/index.php
tr_template_router('post@BlogController');
class BlogController extends TemplateController  
{
    public function __construct()  
    {  
        $this->buildPosts(Post::class);
    }

    public function post()  
    {  
        return tr_view('blog.single', ['posts' => $this->posts]);  
    }
}
(new Page)->whereMeta('featured', 'yes')->get();
(new Post)->published()->with(['meta', 'author.meta'])->paginate();
(new Page)->published()->find()->load(['meta', 'author.meta']);
(new User)->with(['meta'])->get();

ORM + Eager Loading

TypeRocket brings a powerful ORM to WordPress that is designed for WordPress.

// View: blog.single
$this->layout('layouts.blog');

if($posts) : 
foreach($posts as $post) :
    echo '<h1>' . $post->title() . '</h1>';
    echo $post->content();
endwhile;
endif;
// View: layouts.blog
$this->header('parts.header');

$this->yield('main');

$this->footer('parts.footer');

Views

Upgrade from the WordPress spaghetti code to DRY TypeRocket Pro templates.

tr_route()->get()->on('my-api/posts/*', 'post@ApiController');
class ApiController extends Controller  
{
    function posts(Post $post, Response $response) {
        if($post->can('read')) {
            return $post->load(['meta', 'author.meta'])->paginate();
        }

        return $response->unauthorized('No so fast!');
    }
}

Routes

Create custom routes using an elegant syntax. Power up using controllers.

class PostPolicy extends Policy
{
    public function update(AuthUser $auth, WPPost $post)
    {
        if( $auth->isCapable('edit_posts') || $auth->getID() == $post->getUserID()) {
            return true;
        }

        return false;
    }
}
class CanEditUsers extends Middleware {
    public function handle() {

        if( ! $this->handler->getHook() && ! current_user_can( 'edit_users' ) ) {
            tr_abort(401);
        }

        $this->next->handle();
    }
}

Middleware & Policies

Take control of the rest life cycle. Secure your controllers.

// wp-content/themes/my-theme/index.php
tr_template_router('post@BlogController');
class BlogController extends TemplateController  
{
    public function __construct()  
    {  
        $this->buildPosts(Post::class);
    }

    public function post()  
    {  
        return tr_view('blog.single', ['posts' => $this->posts]);  
    }
}

MVC in Themes

Add Pro's MVC to your WordPress theme's template files.

Advanced Controller Features

Laravel developers will feel at home with TypeRocket's MVC features. Here are just a few of the features.

  • Apply controllers to WordPress admin pages
  • Configure controllers to routes
  • Controllers can be classes or functions
  • Add middleware from the controller
  • Request validators
  • Redirect, Request, and Response classes
  • Automatic model record finding
  • Container injection and class resolution