Download the PHP package leeovery/wordpress-to-laravel without Composer

On this page you can find all versions of the php package leeovery/wordpress-to-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wordpress-to-laravel

WordpressToLaravel

Latest Version on Packagist

You want a blog, right? And you want to use the Wordpress backend? But you dislike Wordpress themes, and REALLY dislike creating them? Then this is for you my friend...

This package provides the tool-set to sync WP posts from the WP DB and into your Laravel DB (or wherever you want it to go). This way you can still use the WP backend to author your posts and manage the backend users etc, but gives you glorious freedom to custom code your own frontend, without the nonsense that is WP themes.

It exposes itself as an Artisan command, which means you can set it up to run on a schedule (using Laravel's scheduler) to sync your WP posts, categories, tags and authors to your Laravel DB.

On to installation...

Install

Via Composer:

After adding the package, add the ServiceProvider to the providers array in config/app.php:

Publish the config file:

Migrate your database to setup the posts, categories, tags & author tables:

If you are using wordpress.com to host your blog, set the following env variable to true (default is false). This is done because wordpress.com and wordpress.org (self hosted instances) have different url structure when fetching the posts

Next, add your WP blog url to the env file

or for wordpress.com hosted blogs (change the your-blog part of the url)

Finally, we need to configure WP itself. If you're using Wordpress 4.7+, then you're all set - crack on! Otherwise, you'll need to install the WP API plugin to the WP site you wish to sync from:

Wordpress API

Usage

Firstly, it's best to perform a full sync to get all your posts etc across in one go. After this it'll only sync page 1 of modified posts (by default).

To force sync all published posts:

The -F flag forces all posts to be synced. The -T flag will truncate all the relevant DB tables prior to syncing.

You can rerun that at any time to truncate and resync all your posts etc.

Once that's done, you should setup the following in your Laravel app so that all recently modified WP posts are synced across to the local DB:

Showing Posts

Syncing is only half the job. You'll want to show your posts etc on your blog. But that's super easy too.

Just use the Post, Category & Author Eloquent models that are supplied. Alternatively you can provide your own if you need extra methods or functionality.

For ease I suggest extending from the supplied models. If you want to use your own you should update the config file with your models. Also make sure the transformers work with your model(s) too, otherwise you'll need to supply new versions of those too (they should extend the AbstractTransformer from Fractal), and update the appropriate config value for that models transformer.

Example usage of supplied models (this code would appear in your BlogController, BlogTagController & BlogCategoryController):

Media

When you upload media using the WP backend the links will point to your WP blog url. This might be ok for you. But for us it wasn't. So we installed the S3 plugin on our WP site. This means that all media uploaded via WP will be posted up to your S3 storage, and the URLs to said images will be rewritten on the fly to the S3 location. These updated media urls will be respected when you sync.

Redirecting WP Frontend To New Frontend

Lets say your WP blog is at https://blog.example.com, and your new Laravel frontend is at https://example.com/blog/. Ideally, you'll want your old frontend to redirect to your new frontend. This is simple to achieve by creating a little empty theme and activating it in your WP backend.

  1. Create new theme in your WP themes dir called 'redirection_theme'
  2. Create a file called style.css, and insert the following:

  3. Create a file called index.php, and insert the following:

  4. Finally, create a file called functions.php, and insert the following:

  5. Don't forget to activate it in your WP backend.

Enjoy!

Contributing

Please see CONDUCT for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of wordpress-to-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3
cartalyst/tags Version >=v8.0.0
guzzlehttp/guzzle Version ^7.0
illuminate/database Version ^8.0
illuminate/support Version ^8.0
illuminate/console Version ^8.0
illuminate/contracts Version ^8.0
illuminate/events Version ^8.0
league/fractal Version ^0.19.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package leeovery/wordpress-to-laravel contains the following files

Loading the files please wait ....