Nasrul Hazim Bin Mohamad

Migrate from WordPress to Laravel – Part 1

Dec
22

Assalamualaikum / Hi,

I’ve been using WordPress, since 2012 – 5 years, of service. I think it’s time to migrate to another platform – Laravel. I’ve been reading how murze.be did.

Basically, I got the idea how he did. But, as my sense of explorer, want to learn something new, I read few more articles, packages available out there for migrate from WordPress to Laravel.

I ended up with my own solution.

The idea – use the WordPress REST API.

Of course, I need to prepare my database schema, but I left that part later. What’s important is to grab all the contents from my blog – posts, pages, comments, media, tags, categories and users(since i’m the only author, I don’t have to fetch the user).

Here what I did:

Create the service to call WordPress REST API.

Create an artisan command to fetch all contents.

Do register the artisan command in `Kernel.php`

Then create a `wp` directory in `storage` directory.

So, what I need to do, just call php artisan import:wp http://blog.nasrulhazim.com and I will get as following, store in storage/wp in JSON Pretty Format.

And that’s it for Part 1.

Next, I need to grab all the media, download it to my storage directory.

See you guys on next post.

Laravel: Managing Frontend from Backend

Dec
19

Assalamualaikum / Hi,

A simple user case: How can you setup your frontend from the backend? Means, how you going to display a view, from a value set in database.

For instance, you have a reference table in database named statuses. In the table, you have id,label,name. How do you use values from database to create view – in term of management and usability?

During seeding / add new data: standardised the label name. In my case, I use lower case.

Then, create views based on generated values in label field.

Then here how you can use it. In my case, I have setup relationship with Course model. So that’s how I access to the label field and get the view for the status.

The Result

WordPress: Migration / Deployment

Dec
15

During my first time using WordPress, migrate from one domain to another, it’s a headache for me. Too many steps need to take care off.

Until recently, working in a new company (Rocket Web Sdn Bhd), learning new things using WordPress – hardening, migration, tips & tricks, paid & free plugins.

You may read the summary of deployment(to few servers) from my previous.

The point of this post to highlight the plugins required for deployment/migration.

Duplicator

Duplicator

Create a backup of your WordPress files and database. Duplicate and move an entire site from one location to another in a few steps.

Using Duplicator helps a lot with setting up dumping database and renaming the domain name. Save a lot of your time. You just need to create MySQL user, password and database manually. That’s all you need. I bet there’s much better plugin, but this one work fine for my current tasks.

Better Search and Replace

Better Search and Replace

A small plugin for running a search/replace on your WordPress database.

I use this plugin after the deployment – where I need to rename all the old domain name or any keyword I want to updates. You can select which tables you want to search the keyword and making update. This plugin provide `Run as Dry` – no changes being made unless you un-check this option.

So, these two plugins are useful and easy to use. Hopes will help others doing migration from one server to another.