Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
K

KayueWordpressBundle

> 编程语言
Open source

A Symfony 2 bundle for providing WordPress repositories and authenticating users (login).

99 stars0 likes2 views
WebsiteGitHub

About

A Symfony 2 bundle for providing WordPress repositories and authenticating users (login).

KayueWordpressBundle

Improved version of the original WordpressBundle. The biggest different is this new KayueWordpressBundle won't load the entire WordPress core, thus all the WordPress template funtions won't be available in your Symfony app. This is also the goal of the bundle; do everything in Symfony's way.

I started that bundle two years ago and the original repository grew somewhat chaotically, so I decided to start fresh with new repositories.

Features

  • WordPress authentication (v1.0.0)
  • Custom table prefix (v1.0.1)
  • WordPress entities (v1.0.2)
  • Multisite support (v1.1.0)
  • Twig extension (v1.1.0)
  • WordPress style shortcode (v1.1.0)
  • Major code update. (v2.0.0)
  • Support Symfony 4, new cache configuration (v4.0.0)

Todo

  • Unit test (please help!)

Installation

Composer

composer require kayue/kayue-wordpress-bundle

Register the bundle

…

Twig Extension

This bundle comes with the following Twig extensions.

Functions

  • wp_switch_blog - equivalent to WordPress's switch_to_blog() method.
  • wp_find_option_by - equivalent to WordPress's get_option() method.
  • wp_find_post_by - Get post by ID or slug.
  • wp_find_post_metas_by($post, $key) - equivalent to WordPress's get_post_meta() method.
  • wp_find_post_metas_by({'post': $post, 'key': $key}) - Same as above, accept array as argument.
  • wp_find_comments_by_post($post) - return all approved comments in a post.
  • wp_find_attachments_by_post($post)
  • wp_find_attachment_by_id($id)
  • wp_find_thumbnail($post) - alias of wp_find_featured_image_by_post
  • wp_find_featured_image - equivalent to WordPress's get_the_post_thumbnail method.
  • wp_get_attachment_url($post)
  • wp_get_post_format
  • wp_find_terms_by_post
  • wp_find_categories_by_post - equivalent to WordPress's get_categories() method.
  • wp_find_tags_by_post - equivalent to WordPress's get_tags() method.

Filters

  • wp_autop - Wrap paragraph with tag. Needed for post formatting.
  • wp_texturize - Texturize. Needed for post formatting
  • wp_shortcode - equivalent to WordPress's do_shortcode() method.

To transform extra content like video links or social network links, you can use the Essence Bundle

Multisite

Multisite is a feature of WordPress that allows multiple virtual sites to share a single WordPress installation. In this bundle, each blog (site) has its own entity manager. You need to use blog manager to retrive the blog and then the entity manager.

The following example shows you how to display the latest 10 posts in blog 2.

php
get('kayue_wordpress')->getManager();
    $blogManager->setCurrentBlogId(2);
    $this->getRepository('KayueWordpressBundle:Post')->findOnePostById(1);

    // Method 2: Use entity manager if you don't want to switch the entire blog.
    // This won't change the current blog ID.
    $blogId = 3;
    $anotherBlog = $this->get('kayue_wordpress')->getManager($blogId);
    $posts = $anotherBlog->getRepository('KayueWordpressBundle:Post')->findOneById(1);
}

WordPress Authentication

This bundle allow you to create a WordPress login form in Symfony. All you have to do is to configure the WordPress firewall in your security.yml.

The following example demonstrates how to turn AcmeDemoBundle's login form into a WordPress login form.

…

Shortcode

WordpressBundle support WordPress style shortcode. At the moment the bundle only come with the [caption] and [gallery] shortcode. Pull request is welcome.

To create new shortcode, you need to

  1. extends ShortcodeInterface
  2. tag it with kayue_wordpress.shortcode
php
<?php

use Kayue\WordpressBundle\Wordpress\Shortcode\ShortcodeInterface;

class GalleryShortcode implements ShortcodeInterface
{
    public function getName()
    {
        return 'gallery';
    }

    public function($attr, $content = null)
    {
        // do your things...

        return "
Return HTML
";
    }
}
}
yaml
services:
    acme_demo_bundle.wordpress.shortcode.gallery:
        class: Acme\DemoBundle\Wordpress\Shortcode\GalleryShortcode
        tags:
            - { name: kayue_wordpress.shortcode }

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHP

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言