{"id":241,"date":"2023-01-19T17:56:12","date_gmt":"2023-01-19T14:56:12","guid":{"rendered":"https:\/\/akaunting.com\/hc\/?post_type=docs&#038;p=241"},"modified":"2023-01-21T20:08:53","modified_gmt":"2023-01-21T17:08:53","slug":"modules","status":"publish","type":"docs","link":"https:\/\/akaunting.com\/hc\/docs\/developers\/modules\/","title":{"rendered":"Modules"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Akaunting ships with core accounting tools needed to manage money. It also has a modular structure so that you could extend it. We use the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/akaunting\/laravel-module\" target=\"_blank\">akaunting\/laravel-module<\/a>&nbsp;package as the builder.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A module is like a Laravel package, it has some routes, views, controllers, and models. While technically we call it&nbsp;<code>Module<\/code>, we name it&nbsp;<code>App<\/code>&nbsp;in the UI for the end-user as that\u2019s what they are familiar with.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"e3c260031358\">Folder Structure<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see from the example below, the structure of a module is very similar to a basic Laravel app.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">app\/\nbootstrap\/\nconfig\/\ndatabase\/\nmodules\/\n  \u251c\u2500\u2500 MyBlog\/\n      \u251c\u2500\u2500 Console\/\n      \u251c\u2500\u2500 Database\/\n          \u251c\u2500\u2500 Migrations\/\n          \u251c\u2500\u2500 Seeds\/\n      \u251c\u2500\u2500 Http\/\n          \u251c\u2500\u2500 Controllers\/\n          \u251c\u2500\u2500 Requests\/\n      \u251c\u2500\u2500 Jobs\/\n      \u251c\u2500\u2500 Listeners\/\n      \u251c\u2500\u2500 Models\/\n      \u251c\u2500\u2500 Providers\/\n          \u251c\u2500\u2500 Event.php\n          \u251c\u2500\u2500 Main.php\n      \u251c\u2500\u2500 Resources\/\n          \u251c\u2500\u2500 assets\/\n          \u251c\u2500\u2500 lang\/\n          \u251c\u2500\u2500 views\/\n      \u251c\u2500\u2500 Routes\/\n          \u251c\u2500\u2500 admin.php\n          \u251c\u2500\u2500 portal.php\n      \u251c\u2500\u2500 composer.json\n      \u251c\u2500\u2500 module.json\n      \u251c\u2500\u2500 package.json\n      \u251c\u2500\u2500 webpack.mix.js\npublic\/\n...\nvendor\/\n.env<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"0e88cb6dfd34\">Creating a module<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">There are loads of Artisan commands built-in the module package. For example, let\u2019s see how to make a new module:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">php artisan module:make my-blog<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will create all files and folders shown in the above example.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"67474166c92e\">Installing the module<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now let\u2019s install the module using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">php artisan module:install my-blog 1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>my-blog<\/code>\u00a0is the\u00a0<strong>alias<\/strong>\u00a0of the module and\u00a0<code>1<\/code>\u00a0is the\u00a0<strong>company id<\/strong>\u00a0that you want to install the module.\u00a0<a href=\"https:\/\/akaunting.com\/hc\/docs\/developers\/understanding-the-hierarchy\/\" target=\"_blank\" rel=\"noreferrer noopener\">Here<\/a>\u00a0you can find more about companies in Akaunting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Alias is the unique name of the module as is used everywhere in Akaunting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"fc37d4656f29\">module.json file<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<code>module.json<\/code>&nbsp;file contains the main information about your module such as name, version, providers, etc..<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n    \"alias\": \"my-blog\",\n    \"icon\": \"edit\",\n    \"version\": \"1.0.0\",\n    \"active\": 1,\n    \"providers\": [\n        \"Modules\\\\MyBlog\\\\Providers\\\\Main\"\n    ],\n    \"aliases\": {},\n    \"files\": [],\n    \"requires\": [],\n    \"reports\": [],\n    \"widgets\": [],\n    \"settings\": []\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can check the&nbsp;<strong>Offline Payments<\/strong>&nbsp;module built into the Akaunting core as a live example.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"7ae252e9e978\">Showing to the user<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If your module has pages that need to be shown in the left sidebar, you can check&nbsp;<a href=\"https:\/\/akaunting.com\/hc\/docs\/developers\/menu\/\" target=\"_blank\" rel=\"noreferrer noopener\">this<\/a>&nbsp;article to learn more.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"74cd8a5e37fd\">More<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/akaunting\/module\/wiki\" target=\"_blank\" rel=\"noreferrer noopener\">Module<\/a>&nbsp;documentation can help to understand how the system works.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Akaunting ships with core accounting tools needed to manage money. It also has a modular structure so that you could extend it. We use the&nbsp;akaunting\/laravel-module&nbsp;package as the builder. A module is like a Laravel package, it has some routes, views, controllers, and models. While technically we call it&nbsp;Module, we name it&nbsp;App&nbsp;in the UI for the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":31,"menu_order":3,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-241","docs","type-docs","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/comments?post=241"}],"version-history":[{"count":7,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/241\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/241\/revisions\/274"}],"up":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/31"}],"wp:attachment":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/media?parent=241"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/doc_tag?post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}