The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

Making a module for Akaunting (sponsor)

Published on by

Making a module for Akaunting (sponsor) image

Akaunting is an online, open-source, and free accounting software designed for small businesses and freelancers. It is built with modern technologies such as Laravel, VueJS, Bootstrap 4, RESTful API, etc. From invoicing to expense tracking to accounting, Akaunting has all the basic tools needed to manage money online. For further features, instead of creating a bloated software by adding all of them to the core, we’ve created a modular structure so that it could get extended easily.

Akaunting provides an awesome App Store for users and creates an income channel for Laravel developers all around the world. A module is like a Laravel package, it has some routes, views, controllers, and models. While technically we call it Module, we name it App in the UI for the end-user as that’s what they are familiar with.

So let’s make the first module together:

Install Akaunting

First of all, let’s install Akaunting in 3 basic steps:

  • Clone the repository: git clone https://github.com/akaunting/akaunting.git
  • Install dependencies: composer install ; npm install ; npm run dev
  • Install Akaunting:
php artisan install --db-name="akaunting" --db-username="root" --db-password="pass" --admin-email="admin@company.com" --admin-password="123456"
  • Create sample data (optional): php artisan sample-data:seed

Make a module

The akaunting/module package is used as builder. There are loads of Artisan commands built-in the package. For example, let’s make a new module:

php artisan module:make my-blog

This will create all files and folders. Now let’s install the module:

php artisan module:install my-blog 1

my-blog is the alias of the module and 1 is the company id that you want to install the module. Here you can find more about companies in Akaunting.

Alias is the slug/unique of the module as is used everywhere in Akaunting.

Folder Structure

As you can see from the example below, the structure of a module is very similar to a basic Laravel app.

app/
bootstrap/
config/
database/
modules/
├── MyBlog/
├── Console/
├── Database/
├── Migrations/
├── Seeds/
├── Http/
├── Controllers/
├── Requests/
├── Jobs/
├── Listeners/
├── Models/
├── Providers/
├── Main.php
├── Resources/
├── assets/
├── lang/
├── views/
├── Routes/
├── admin.php
├── portal.php
├── composer.json
├── module.json
├── package.json
├── webpack.mix.js
public/
...
vendor/
.env

module.json file

The module.json file contains the main information about your module such as name, version, providers, etc..

{
"alias": "my-blog",
"icon": "fas fa-pen",
"version": "1.0.0",
"category": "accounting",
"active": 1,
"providers": [
"Modules\\MyBlog\\Providers\\Main"
],
"aliases": {},
"files": [],
"requires": [],
"reports": [],
"widgets": [],
"settings": []
}

Adding module to left sidebar/menu

You may want to extend the menu by adding your own pages. In such a case, you can listen to the AdminCreated event for admin and/or PortalCreated for client sides.

Let’s firstly create the listener:

<?php
 
namespace Modules\MyBlog\Listeners;
 
use App\Events\Menu\AdminCreated as Event;
 
class AddMenu
{
/**
* Handle the event.
*
* @param Event $event
* @return void
*/
public function handle(Event $event)
{
// Add child to existing menu item
$item = $event->menu->whereTitle(trans_choice('general.sales', 2));
$item->url('my-blog/posts', 'Posts', 4, ['icon' => '']);
 
// Add new menu item
$event->menu->add([
'url' => 'my-blog/posts',
'title' => 'Posts',
'icon' => 'fas fa-pen',
'order' => 5,
]);
}
}

Then add your listener into the $listen array of your Modules\MyBlog\Providers\Event service provider:

'App\Events\Menu\AdminCreated' => [
'Modules\MyBlog\Listeners\AddMenu',
],

Menu documentation can help to understand the system, especially about how to find a menu item, add child ones, and create dropdown menus.

Settings page

Akaunting ships with a centralized settings page where modules can add their own in a few steps. Mostly, developers just want to add just some inputs on the settings page. In such a case, you can add them to the module.json file and Akaunting will display your module under the Settings page, nothing else is required.

All you have to do is to fill the settings array like the following:

"settings": [
{
"type": "textGroup",
"name": "title",
"title": "my-blog::general.title",
"icon": "font",
"attributes": {
"required": "required"
},
"rules": "required|string"
},
{
"type": "textGroup",
"name": "header",
"title": "my-blog::general.description",
"icon": "user",
"attributes": {},
"rules": "nullable|string"
}
]

If your settings page needs a little bit more actions then you can check this article.

Go go go

Now you’re ready to go to the Main controller and start writing the code you want just like in a basic Laravel app. For sure that there are more to learn about Akaunting module development such as overriding output, hooking models, handling permissions, and a lot more.

Start today

As you can see it’s easy peasy to make a module for Akaunting and create a new income channel. Join a strong community of accounting innovators and gain access to the fastest-growing accounting SMB base.

Finally, don’t forget to check our GitHub repository. Pull requests are more than welcome :-)

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Filed in:
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing

The latest

View all →
Laravel Schema Sentinel: Detect and Fix Database Schema Drift image

Laravel Schema Sentinel: Detect and Fix Database Schema Drift

Read article
Laravel Web Push Notifications image

Laravel Web Push Notifications

Read article
RedBerry to Host Georgia's First Laravel Meetup in Tbilisi image

RedBerry to Host Georgia's First Laravel Meetup in Tbilisi

Read article
Interruptible Jobs in Laravel 13.7.0 image

Interruptible Jobs in Laravel 13.7.0

Read article
A Free Shift to Check If Your App is Ready for Laravel Cloud image

A Free Shift to Check If Your App is Ready for Laravel Cloud

Read article
Laravel Idempotency: HTTP Idempotency Middleware for Laravel image

Laravel Idempotency: HTTP Idempotency Middleware for Laravel

Read article