Laravel and WordPress series-integration of Laravel and WordPress extension packages

Source: Internet
Author: User
Tags wordpress database
Laravel and WordPress series-integration of Laravel and WordPress expansion package Daquan WordPress is one of the world's most popular open source applications, according to statistics, 20% of the world's websites are developed based on WordPress, it is very convenient to use WordPress to manage the background, publish articles, add menus, and upload images. Therefore, sometimes we want to build applications using the WordPress background, but we want to have more custom space on the foreground, we can perform various flexible development like Laravel. The good news is that there are many extension packages for Wordpress backend + Laravel front-end on Github. let's take a look at the following:

WordPress Corcel

Corcel uses the LaravelEloquent model to directly obtain the content from the WordPress database. after installation, you can obtain the model data through the following Laravel-style code:

// All published posts$posts = Post::published()->get();$posts = Post::status('publish')->get();// A specific post$post = Post::find(31);

The extension package supports articles, document types, tags, pages, categories, and attachments. However, the extension package is still in the development process and has not been released in the official version.

WordPressToLaravel

WordPressToLaravel is used to synchronize blog data from WordPress.com. it is designed to run as a scheduling task through Laravel Scheduler, automatically download and import the article data to the local database.

After the setup is complete, you need to write model classes, controllers, and view code that match your own database. the advantage of using WordPress.com is that it can automatically handle WordPress upgrades, CDN technology can be used to publish content through websites, mobile apps, and desktop apps.

The disadvantage is that this extension package can only be used to publish document data and does not support classification and tags.

WP Eloquent

WP Eloquent is an extension package used to create a Press Data Table model that encapsulates Wor, including the Post, Comment, Post Meta, User, and User Meta model classes. The following is an example after installation:

use WeDevs\ORM\WP\Post as Post;Post::type('page')->get()Post::status('publish')->get()Post::type('page')->status('publish')->get()

WP Eloquent can also work with Laravel DebugBar without creating redundant database connections.

Laravel-wp-api

Laravel-wp-api integrates the WordPress json rest api. after installation, you can use the alias WpApi to query data:

$post = WpApi::post($slug);$catPosts = WpApi::category_posts($slug, $page);

Other methods for integrating WordPress and Laravel

Of course, integrating WordPress and Laravel is not limited to the above extension packages. Below are some articles and tutorials on how to manually integrate the two:

  • WordPlate is built based on the Laravel and Symfony components and uses WordPress as the dependency
  • Integrate WordPress and Lumen
  • Set up Laravel API integrated into the WordPress background
  • Integrate Laravel 4 + Eloquent and WordPress

As you can see, there are many ways to integrate WordPress and Laravel, depending on your needs and goals. In any case, there is always a suitable one for you ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.