Laravel Blog Package
Happy New Year 🙂
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 blog package 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:
https://github.com/vhessam/hessam-cms/discussions
New Surprising Feature: Multi-language
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 CMS has 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 🙂
Table of Contents
- Feasible Solutions
- Laravel WordPress
- Hessam CMS Demo Video
- Preview For Admin Interface
- Minimum Requirements
- Benefits
- Setup Instructions
- Full Package Support
- Captcha
- Release History / Recent Changes
Feasible Solutions
For the above mentioned requirements you have several solutions. Let’s see the solutions.
- A package which provides your laravel website with blog 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.”
— Andrew Coghlan- Director at FullClarity
Laravel and WordPress CMS
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.
Preview For Admin Interface



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:
composer require laravel/ui
php artisan ui vue --auth
- Run the following two commands to copy config file, migration files, and view files
php artisan vendor:publish --provider="HessamCMS\HessamCMSServiceProvider"
- Execute migrations to create tables
php artisan migrate;
- 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/
namedblog_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 ishessamcms::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
In conclusion, 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.
Comments
22 Comments
Many thanks for this nice and useful package.
Thanks to the community 😉 🙂
Many thanks for this nice package
😉 again, thanks to the open community.
Hello,
Thank you for this package which looks really good.
For me the installation worked well and I was able to access “Blog” and “blog_admin”. I created categories and uploaded images, so far so good. But as soon as I create a Post, it saves itself well in the database, but if I go to “blog” or “blog_admin” I get the following message:
Error
Class ‘App\User’ not found (View: D:\wamp64\wwww\blog\resources\views\vendor\blogetc\partials\index_loop.blade.php)
Do you know why I have this error?
Thank you in advance for your help.
stephane
hi,
I solve the problem.
In the file \configetc.php I had :
‘user_model’=>\App\User::class,
I replaced with :
‘user_model’=>\App\Models\User::class,
and everything now works perfectly.
Stéphane
Hi Stéphane, happy that you found the solution for this issue.
Yes this issue is for laravel 8, in latest laravel version the user model is relocated to \App\Models\.. . I try to keep package more compatible with LTS version of laravel.
Many thanks for your consideration Stéphane.
Hi hessam,
Is it possible to communicate with you directly by email?
I tried several times to redo an installation of your package from scratch and each time I have the same concern when I want to go on blog_admin – 401 UNAUTHORIZED, then I am well connected, on the home page I have : Dashboard
You are logged in!
Thank you in advance for your response.
Sincerely
stephane
Hi Stephane,
yes feel free to communicate with me by email, I’m available to ask everything you need.(hessam.modaberi@gmail.com)
If you get this error.. it seems that you did not set the appropriate method in User model.
You must add this method to your user model:
Many thanks
I have a custom guard and model called Admin
How do I make my admin access blog admin?
I added this code into my Admin model and when I am logged in as admin, I hot a Unauthorized when I access the blog admin
“`
public function canManageHessamCMSPosts()
{
return true;
}
“`
Hi John,
1- be sure that you are logging in as admin user
2- if you have another user model except the default in: \App\User\Models change the “user_model” config in hessamcms.php config file
I’m still hitting a 401, any ideas?
In the hessamconfig I have
//Change it to \App\User::class for previous laravel versions
‘user_model’=>\App\Admin::class,
And in my Admin class I have
public function canManageHessamCMSPosts()
{
if(1){
return true;
}
}
let me know your full URL which you are accessing..
http://localhost:3000/blog_admin
check that your \Auth::user() contains the logged in admin user. With your customization, may be it’s not referring to your admin user.
Auth::guard(‘admin’)->user()
This is the line to access my logged in user….do I need to replace all Auth::user() in your code?
I have replaced Auth user with my custom guard, now I am getting this error of:
Trying to get property ‘locale’ of non-object
in vendor\hessam\laravel-blogger\src\Middleware\LoadLanguage.php:19
Great!
So, you must first setup package by accessing this link: /blog_admin/setup
Excellent. I am nearly there.
I can now see the dashboard for blog.
I can add a new category.
But I can’t create a post or upload a new image – I get a 403 Error : Forbidden
Any tips?
Great! check that you’ve created the blog_images dir below the public dir, and be sure it’s writable.
Do you have any idea why if I go to /blog it comes with a 404 error code?
Sorry for all the questions.
Feel free to ask everything you want. This package supports multi language, you should access your blog at “/en/blog”