Laratalks #10 – Laravel Macros, Corcel, and WordPress

Another Laratalks on the weekday!

It was the 10th meetup, which means 10 in a row. Good job, Ajay and Aiyas, and the community.

Laratalks

Laratalks is a series of monthly meetups for Laravel developers that were founded by Ajay and Aiyas. Due to their efforts, the meetup attracts many developers who wouldn’t normally know each other and they get to make new connections. The greater part is that it gives a chance to the developers to share their ideas and experience related to Laravel, PHP and web development with the community.

Laratalks #10

In this Laratalks the talks were about:

  • A less noticeable but powerful feature, Laravel Macros
  • A package to use WordPress as backend in Laravel, Corcel
  • and, an interesting way to use WordPress theme in Laravel

Laravel Macros

In the first talk, Nasrul Hazim, who was a Software Developer from SumberManusia.my, who shared a less noticeable but powerful feature — Laravel Macros.

Nasrul

Macros help you to extend the Facade’s functionality. Macros were not widely introduced in the documentation but it is documented here.

How does it work?

Let’s said you’d like to extend the URL facade to provide a common landing page URL.

Now you can refer to the landing page URL anywhere in your blade file.

By adding a meaningful macro, the Laravel’s facades became more relevant to your business logic. For example, response()->downloadPdf().

If you’d like to know more about the classes which support Macros, you can search for the Trait, Macroable in your project.

However, it was easy to create a mess and a less manageable codebase when you have too many macros. Nasrul advised you to check out Laravel collection macros before you start to introduce macros into your project.

If you’d like to learn more Nasrul’s talk, check out his Github repo.

Next, Ajay introduced a package which made Laravel worked perfectly with WordPress.

Laravel & Corcel

Ajay Madhukar, a full stack web developer from Squincy, introduced a package that allows you to use WordPress as backend (content management system) and to retrieve its data using Eloquent, within any PHP or Laravel project.

Ajay

Corcel consumes WordPress database data in Laravel through the Eloquent ORM. You can retrieve the posts from the WordPress database directly in Laravel.

Some examples,

No doubt WordPress is the most popular content management system. This package saves you hundreds of hours on developing such a powerful CMS from scratch.

If you like this topic, check out Ajay’s presentation slide at Google Drive,

If you’d like to learn more about Corcel, check out the Github repo.

With Corcel, Laravel served as frontend and WordPress served as backend.

Interestingly, the next speaker shared a concept which reversed the role of Laravel and WordPress.

Using WordPress Theme in Laravel

To be honest, it was not exactly WordPress served as a frontend and Laravel served as a backend, but it was pretty close.

Nicolas Yip, a frontend developer, shared an interesting idea on how to adopt the WordPress theme in your Laravel application.

Nicolas

His idea was, 1. copy the WordPress theme folder into the project folder resources/views 2. convert the HTML files into Blade templates

Nicolas proved that it was achievable to use WordPress theme in Laravel, even if you don’t have a designer friend.

Nicolas said, “Blade template documention is your best friend. Make sure you bookmark the web page before you start.”.

If you love Nicolas’s idea, check out his presentation slide at Google Drive.

The three talks were short but fruitful. It gave Ajay more time to share in the lightning talks.

Packages worth to check out

Ajay mentioned two packages were worth a save into your bookmarks.

Something worth mentioning, a brave man (sorry buddy, I didn’t know your name yet) who came forward and shared with us his first Laravel project. He shared his experience on learning Laravel from zero to delivering first Laravel application.

I believe that his courage action delivered a strong message. That you should be proud of what you’ve done.

“No effort is a shame to tell. This is not competition.”

Laratalks & Laravens

Laravens is a community for Laravel lovers. It aims to bring developers from different walks of life together and to help them learn and grow within the community.

They do so by organising events like Laratalks. This is a monthly event where developers get to share interesting tricks of the trade, hacks, lessons and their expertise about Laravel, PHP and web development in general.

They also organise informal events like Laratlks where developers get to network with one another.

Conclusion

Joining and contributing to the community is the key to keep improving in your programming life.


Also published on Medium.