Have you ever heard this question? If yes, so there is a misunderstanding. Simply, PHP is a language and Laravel is a PHP web framework you use for simplifying the hardwork.
If you want to choose between php pure or a php framework, readthis article.
If you’ve heard about php frameworks like Laravel, Symfony, CodeIgniter etc, you may ask yourself why should I use these frameworks? When I can get request parameters, store data and handle my logic, why should I use frameworks?
A Story
Let me demonstrate the future problem with a story. Think of when you get your programming project, and you start to plan for this project. For example a simple accounting project. First you design a simple UI with HTML and CSS, and you continue with defining user flows and use cases for this application (naturally our solution for this accounting application is web application). At this step you know about application processes, for example you know you have a login page, you have a page to define employees and something like that. So, now you have everything to start coding with pure php. You know php syntax and you do coding very well, and all is done. You make it very well.
The problem arises
By now everything is fine! And application is ready to use. After 6 months you decide to add new feature, or your employer tells you new business needs (we know that every feature comes from a business need, and the most important thing is that the business needs are endless. Agile).
So, now you should come back and do some refactoring (changing existing code to meet current needs) or in best situation you must add some code. But you find out that you do not remember why you created some classes, their role and how they really work! (think about this situation for more complex applications and software). So you are in trouble..! What is the solution for this situation? You start to define some structure for your coding, may be even more commenting, and defining some conventions (for example you group classes with directories). And if you do it very well that means you are creating your own framework 🙂
Conclusion
The main reason to use a framework is to escape from an unstructured code (known as spaghetti code which you cant find any rule within it). Also it has many other benefits, for example when people follow a common standard, they can help each other, and code for other systems and applications (mostly developers have indirect cooperation through packages). It worth to mention that this is not only for pure php, the scenario is the same for other languages.
Just look at the outstanding features, then continue reading (Jump into the Installation instead):
Full Text Search – Searching throughout all blog posts
Multi Level Categories – Nested sets pattern using Baum
Multi Language Support – Ability to translate each post
If you are looking for a blog solution for your laravel website, I recommend to use a laravel blogpackage instead. In this article I’ll show you how to install and use a great laravel blog package (laravel 8 blog) which adds blog/cms functionality to your website and is compatible with latest Laravel version (now laravel 8). Firstly let me explain the problem which I encountered when I wanted to have a blog functionality for my laravel project.
My scenario has some requirements for a blog system, for example the blog functionality must support commenting, defining categories for posts (plus multi-level category support), being light-weight, giving front-end, and being flexible for further customization. Also preferably it’s better to use a free solution. I explained my options In “Feasible Solutions” section.
You can check the online demo before you install it yourself. Feel free to start any discussion on Github:
Even WordPress and some other CMS platforms does not have multi-language support out-of-box. You may need to do some tricks to to implement that for your blog. For example, in WordPress you can use another instance along with your main WordPress instance for an additional language. Then you must sync databases. So, you have an extra burden to setup your blog system.
Hessam CMShas multi-language feature out-of-box. Easily use common languages and translate your posts.
We were planned to update the package on December first but we completed it sooner. All improvements are possible with your support 🙂
For the above mentioned requirements you have several solutions. Let’s see the solutions.
A package which provides your laravel websitewithblog functionality
Using some platforms which act as a basis for our website – actually they are a complete Laravel setup. Therefor these platforms have their own structure, and you need to learn their coding..
Integration with other blogging platforms – in this scenario you have your own models and business logics, and you connect these models to your blogging systems like WordPress. For example: you have access to your WordPress posts and your categories inside your laravel code, you can manipulate in your code and etc.
Using a separate blogging system – You have a blogging system (Joomla, Drupal, WordPress) along with your main laravel webasite. So you can link to your blog section (which is a link to your Joomla project) inside your main website (for example a /blog link in nav bar). Keep in mind that in this scenario blog users and your laravel users are separated.
So it’s up to you to choose among these solutions, but I prefer a solution which does not make me dependent to any platform, plus ease of customization. Preferably a Laravel CMS package (laravel 8 blog – laravel blog package). I explained the reasons in more detail in this article.
What others say..
“I was looking for quite a while for a Laravel CMS I could use that allowed me to use _all_ of Laravel’s current features. Even the big ones like October are limited to operating on v6; I get it – they want the LTS version, but in my specific case it limited the ability to do want I wanted.
A key will be that it’s updated in line with Laravel to always work on the latest version. None of the other CMSs work on anything above Laravel v6 – and some are stuck on v5. That’s no good.
The way your system works, I can do exactly that.”
Many websites use wordpress as their publishing platform. Regardless which framework you use for your website or web application (for example Django, Flask, Symfony, CodeIgniter, Spring Boot, MVC .Net, Ruby on Rails and even the most popular Laravel), it’s very common to use wordpress as publishing platform and CMS to have a blog and manage blog posts. In case of Laravel there are many Laravel CMS and publishing platforms like October. CMS platforms like October are very powerful and robust, but it’s not a good idea for existing websites and existing codes. They impose their own structures really they are a blogging frameworks over Laravel frameworks. So when you use them you do not feel comfortable. To work with them correctly you need to read more about them and learn additional concepts.
But easily you can add a Laravel CMS / Laravel Blog, to your website without worry about your models, business logic and existing code. Hessam CMS is a laravel package which provides your website with a blogging system like WordPress.
Hessam CMS Demo Video
In this video the installation process and a quick overview is shown. After following this video you have a nice blog system for your Laravel website.
Create new postShows all posts in admin panelAdd new category
Minimum Requirements
All of the requirements are installed during package installation.
Benefits
Everyone who use Laravel framework, can get benefit from this package. You can customize it and make any changes to fit your needs. So this works with your existing user and role management too.
This package gives you a dashboard to manage your blog and posts and a front-end to show your posts. So you can customize the blade templates to be fit with your UI. In other words I try to make admin UI familiar with WordPress admin panel. Actually working with this panel is much easier than working with WordPress admin panel.
Setup Instructions
Install via composer
composer require hessam/laravel-blogger
For a fresh Laravel installation run the following too:
You must add one method to your \App\User (in laravel 8 \App\Models\User) model. As the name of this method shows it determines which user can manage posts. Place your logic there.
/**
* Enter your own logic (e.g. if ($this->id === 1) to
* enable this user to be able to add/edit blog posts
*
* @return bool - true = they can edit / manage blog posts,
* false = they have no access to the blog admin panel
*/
public function canManageHessamCMSPosts()
{
// Enter the logic needed for your app.
// Maybe you can just hardcode in a user id that you
// know is always an admin ID?
if ( $this->id === 1
&& $this->email === "your_admin_user@your_site.com"
){
// return true so this user CAN edit/post/delete
// blog posts (and post any HTML/JS)
return true;
}
// otherwise return false, so they have no access
// to the admin panel (but can still view posts)
return false;
}
Create a directory in public/ named blog_images
Login as admin and setup your package: /blog_admin/setup
Congrats! Your blog is ready to use. (URLs are customizable in the config file) Admin panel URI:/blog_admin Front URI: /en/blog
I work on this package to add more features. I have some to-dos for this that I list it here. You can comment if you see something is missing or is necessary.
Star the package on github:
Full Package Support
I try to add more features and answer issues and fix bugs as soon as possible. Contact me to tell me which features you want, then I plan to create them (You will get response under 3 hour). Moreover I’m online most of the time feel free if you need tips, you can talk to me with online chat or other channels.
So it’s better to create an issue on Github to report a bug fix. Github Issues
Captcha
To enable or disable captcha, check captcha config in config/hessamcms.php file. A simple captcha system is created already, but you can add your logic or your replace the existing. To add your captcha system you have to implement CaptchaInterface and update the class in config/hessamcms.php file.
There are three methods which must be implemented in your class.
public function captcha_field_name(): Returns a string for form validation for example “captcha” <input name="..">.
public function view(): This returns the related view file which must be added into the appropriate blade file. The default file is hessamcms::captcha.basic.
public function rules(): Return an array for the rules (which are just the standard Laravel validation rules). This is where you can check if the captcha was successful or not. For example for google reCaptcha you must do server-side checking here.
Optional: public function runCaptchaBeforeShowingPosts(): This isn’t part of the interface, it isn’t required. By default it does nothing. But you can put some code in this method and it’ll be run in the HessamCMSReaderController::viewSinglePost method.
Release History / Recent Changes
Multi language support – version 9.x
Compatibility with Laravel 8 (laravel 8 blog) – version 8.0.x
New Admin UI – version 7.3.2
Multi-Level Category functionality – version 7.2.x
Ability to remove images from posts, updated CKEditor – version 7.1.8
Updated Fulltext search package – I added a feature to swisnl/laravel-fulltext package (through a pull request) to fix an issue in search functionality. It’s important to do the config setups to work this search properly, otherwise it returns blogs which are not published in search result – version 7.1.4
Support for custom user model – version 7.1.0
Made compatible with Laravel 6.x & 7.x – version 7.0.1
Conclusion
Inconclusion, as a technical head or as a product owner, you are responsible to choose appropriate solutions for your projects. So, it’s better to use tools and packages which give you flexibility and ease of use. Definitely you do not want to deep dive into complex structures and development process. This CMS package will save your time too much.
In this article, first I’ll tell you what problems I encountered and then I assess some existing Laravel platforms for laravel blogs.
The Scenario
First let me explain the scenario that I dealt with it. Consider when you have a Laravel project and you want a blog functionality for it.
My scenario has some requirements for blog system, for example the blog functionality must support commenting, defining categories for posts, light-weight, giving front-end, and flexible for further customization. Also preferably it’s better using a free solution.
Feasible Solutions
Based on the mentioned requirements (even without the requirements), we have some solutions:
The easiest way is to use a package which provides blog functionality
Using some platforms which act as a basis for our website, really they are a complete Laravel setup
Integration with other blog platforms like the most popular WordPress
Using a separate blogging system
Let’s look at each of these ways. But I begin from the last solution. Also obviously there is a solution that you can build a blog system from scratch which fits your needs exactly, but you should consider all aspects of a blog.
Integration with other Platforms
I checked integration with WordPress. There are some ways and packages to do it. you can check this article to know more about this.
This approach has some big drawbacks for example it has an overhead over your website and for some scenarios it’s a little complicated. You can also try to share sessions between Wordpres and your Laravel website through JWT or a solution like Auth0 which acts as a intermediate layer between your WordPress and your Laravel website. Also there are some considerations, this approach assumes you use WordPress as your authentication engine which may conflicts with your needs.
If you use this approach and handle these drawbacks this is the best way, because you get benefit from a powerful platform like WordPress which is specifically designed for blogs.
A Complete Laravel Setup
There are powerful platforms which give you a fresh setup to your website and you can build your logic over them. One of the most popular is October cms. When you install this software you have a complete Laravel website. But when you see the underlying code, the structure is a little different from the fresh Laravel setup. It also offers new concepts over the Laravel. Also it does not support commenting out of box. All of these issues show that you need another expertise plus your Laravel knowledge to develop your business logic. And for your existing Laravel project it has nothing to say.
Other platforms like Pyrocms and Lavalite have same issues. In Pyrocms you must pay for commenting functionality.
The main issue with these platforms is that you should adapt yourself and logics to their platform and you must learn to develop them.
Blog Packages
Canvas and other publishing platforms have good editors but they have big drawbacks, like lack of front-end, weak customizability, and also lack of commenting..
Twill platform has some drawbacks like October platforms, which you must spend much time to learn about customization. Also Twill has its own models for user authentication!
To solve these problems I started a project (a laravel package) which meets all of these requirements. You can read more about this package at this article.
Conclusion
It’s up to you to choose between these solutions, but I prefer a solution which does not make me dependent to any platform, and ease of customization is one of my considerations.