{"id":23259659,"url":"https://github.com/italia/design-laravel-theme","last_synced_at":"2026-01-11T10:42:42.068Z","repository":{"id":56994047,"uuid":"178837530","full_name":"italia/design-laravel-theme","owner":"italia","description":"Easy Bootstrap-Italia integration with Laravel 5","archived":false,"fork":false,"pushed_at":"2024-11-19T13:51:51.000Z","size":4992,"stargazers_count":14,"open_issues_count":2,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-29T01:41:23.608Z","etag":null,"topics":["design","laravel","php"],"latest_commit_sha":null,"homepage":"https://design-laravel-theme.herokuapp.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/italia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-01T10:12:45.000Z","updated_at":"2024-11-19T13:51:55.000Z","dependencies_parsed_at":"2022-08-21T10:40:40.752Z","dependency_job_id":null,"html_url":"https://github.com/italia/design-laravel-theme","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italia%2Fdesign-laravel-theme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italia%2Fdesign-laravel-theme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italia%2Fdesign-laravel-theme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italia%2Fdesign-laravel-theme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/italia","download_url":"https://codeload.github.com/italia/design-laravel-theme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230438174,"owners_count":18225870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["design","laravel","php"],"created_at":"2024-12-19T13:01:07.884Z","updated_at":"2026-01-11T10:42:42.012Z","avatar_url":"https://github.com/italia.png","language":"PHP","funding_links":[],"categories":["📐 Design"],"sub_categories":[],"readme":"# Easy Bootstrap-Italia integration with Laravel\r\n\r\n[![Join the #design-cms-themes channel](https://img.shields.io/badge/Slack%20channel-%23design--cms--themes-blue.svg?logo=slack)](https://developersitalia.slack.com/messages/C91K0K085)\r\n[![Get invited](https://slack.developers.italia.it/badge.svg)](https://slack.developers.italia.it/)\r\n[![Design on forum.italia.it](https://img.shields.io/badge/Forum-Design-blue.svg)](https://forum.italia.it/c/design/user-interface) [![Latest Stable Version](https://poser.pugx.org/italia/design-laravel-theme/v/stable.png)](https://packagist.org/packages/italia/design-laravel-theme)\r\n [![Total Downloads](https://poser.pugx.org/italia/design-laravel-theme/downloads.png)](https://packagist.org/packages/italia/design-laravel-theme)\r\n\r\nThis package provides an easy way to quickly set up [Bootstrap Italia](https://italia.github.io/bootstrap-italia/) with \r\nLaravel. It has no requirements and dependencies besides Laravel, so you can start building your website immediately. \r\nThe package just provides a Blade template that you can extend and advanced menu configuration possibilities. \r\n\r\n1. [Installation](#1-installation)\r\n2. [Updating](#2-updating)\r\n3. [Usage](#3-usage)\r\n4. [The `make:bootstrapitalia` artisan command](#4-the-makebootstrapitalia-artisan-command)\r\n5. [Configuration](#5-configuration)\r\n   1. [Menu](#51-menu)\r\n     - [Custom menu filters](#custom-menu-filters)\r\n     - [Menu configuration at runtime](#menu-configuration-at-runtime)\r\n     - [Active menu items](#active-menu-items)\r\n5. [Translations](#6-translations)\r\n6. [Customize views](#7-customize-views)\r\n7. [Issues, Questions and Pull Requests](#8-issues-questions-and-pull-requests)\r\n\r\n## 1. Installation\r\n\r\n1. Require the package using composer:\r\n\r\n    ```\r\n    composer require italia/design-laravel-theme\r\n    ```\r\n\r\n2. Add the service provider to the `providers` in `config/app.php`:\r\n\r\n    \u003e Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider\r\n\r\n    ```php\r\n    italia\\DesignLaravelTheme\\ServiceProvider::class,\r\n    ```\r\n\r\n3. Publish the public assets:\r\n\r\n    ```\r\n    php artisan vendor:publish --provider=\"italia\\DesignLaravelTheme\\ServiceProvider\" --tag=assets\r\n    ```\r\n\r\n## 2. Updating\r\n\r\n1. To update this package, first update the composer package:\r\n\r\n    ```\r\n    composer update italia/design-laravel-theme\r\n    ```\r\n\r\n2. Then, publish the public assets with the `--force` flag to overwrite existing files\r\n\r\n    ```\r\n    php artisan vendor:publish --provider=\"italia\\DesignLaravelTheme\\ServiceProvider\" --tag=assets --force\r\n    ```\r\n\r\n## 3. Usage\r\n\r\nTo use the template, create a blade file and extend the layout with `@extends('bootstrap-italia::page')`.\r\nThis template yields the following sections:\r\n\r\n- `title`: for in the `\u003ctitle\u003e` tag\r\n- `content`: all of the page's content\r\n- `css`: extra stylesheets (located in `\u003chead\u003e`)\r\n- `js`: extra javascript (just before `\u003c/body\u003e`)\r\n\r\nAll sections are in fact optional. Your blade template could look like the following.\r\n\r\n```html\r\n{{-- resources/views/test.blade.php --}}\r\n\r\n@extends('bootstrap-italia::page')\r\n\r\n@section('title', 'Bootstrap Italia')\r\n\r\n@section('content')\r\n    \u003cp\u003eTest page.\u003c/p\u003e\r\n@stop\r\n\r\n@section('css')\r\n    \u003clink rel=\"stylesheet\" href=\"/css/custom.css\"\u003e\r\n@stop\r\n\r\n@section('js')\r\n    \u003cscript\u003e console.log('Hi!'); \u003c/script\u003e\r\n@stop\r\n```\r\n\r\nNote that in Laravel 5.2 or higher you can also use `@stack` directive for `css` and `javascript`:\r\n\r\n```html\r\n{{-- resources/views/test.blade.php --}}\r\n\r\n@push('css')\r\n\r\n@push('js')\r\n```\r\n\r\nYou now just return this view from your controller, as usual. Check out [Bootstrap Italia](https://italia.github.io/bootstrap-italia/) to find out how to build content for your pages.\r\n\r\n## 4. The `make:bootstrapitalia` artisan command\r\n\r\n\u003e Note: only for Laravel 5.2 and higher\r\n\r\nThis package ships with a `make:bootstrapitalia` command that behaves exactly like `make:auth` (introduced in Laravel 5.2). In the near future it will publish auth views with bootstrap-italia styles.\r\n\r\nIt will also create custom pagination links views under `vendor/pagination` folder\r\n\r\n```\r\nphp artisan make:bootstrapitalia\r\n```\r\n\r\nThis command should be used on fresh applications, just like the `make:auth` command\r\n\r\n\r\n## 5. Configuration\r\n\r\nFirst, publish the configuration file:\r\n\r\n```\r\nphp artisan vendor:publish --provider=\"italia\\DesignLaravelTheme\\ServiceProvider\" --tag=config\r\n```\r\n\r\nNow, edit `config/bootstrap-italia.php` to configure the title, theme, menu, URLs etc. All configuration options are explained in the comments. However, I want to shed some light on the `menu` configuration.\r\n\r\n### 5.1 Menu\r\n\r\nYou can configure your menu as follows.\r\n\r\nBasically, you have three keys: `slim_header`, `header` and `footer`, which defines how the three sections are \r\nconfigured:\r\n\r\n```php\r\n'menu' =\u003e [\r\n    'slim-header' =\u003e [],\r\n    'header' =\u003e [],\r\n    'footer' =\u003e [],\r\n    'footer-bar' =\u003e [],\r\n],\r\n```\r\n\r\n`slim_header` and `footer_bar` are configured as\r\n```php\r\n'menu' =\u003e [\r\n        'slim-header' =\u003e [\r\n            [\r\n                'url' =\u003e '#',\r\n                'text' =\u003e 'Pagina iniziale',\r\n            ],\r\n            [\r\n                'url' =\u003e '#',\r\n                'text' =\u003e 'Contatti',\r\n                'target' =\u003e '_blank',\r\n            ],\r\n        ],\r\n        ...\r\n]        \r\n``` \r\n\r\n```php\r\n'menu' =\u003e [\r\n        'footer-bar' =\u003e [\r\n            [\r\n                'url' =\u003e '#',\r\n                'text' =\u003e 'Privacy policy',\r\n            ],\r\n            [\r\n                'url' =\u003e '#',\r\n                'text' =\u003e 'Contatti',\r\n                'target' =\u003e '_blank',\r\n            ],\r\n        ],\r\n        ...\r\n]        \r\n``` \r\n\r\n`footer` is configured as\r\n```php\r\n'menu' =\u003e [\r\n        ...\r\n        'footer' =\u003e [\r\n                    [\r\n                        [\r\n                            'text' =\u003e 'Amministrazione',\r\n                            'url' =\u003e '#',\r\n                            'target' =\u003e '_blank',\r\n                        ],\r\n                        [\r\n                            'text' =\u003e 'Giunta e consiglio',\r\n                            'url' =\u003e '#',\r\n                        ],\r\n                    ],\r\n                    [\r\n                        [\r\n                            'text' =\u003e 'Amministrazione',\r\n                            'url' =\u003e '#',\r\n                        ],\r\n                        [\r\n                            'text' =\u003e 'Giunta e consiglio',\r\n                            'url' =\u003e '#',\r\n                        ],\r\n                    ],\r\n                ],\r\n]        \r\n``` \r\n\r\nwhile `header` is more complex, since each element could be an `string`, a `simple item`, a `dropdown` or a `megamenu`:\r\n\r\n- `string` is just a string without links\r\n- a `simple item` is an associative array with the form: \r\n```php\r\n[\r\n    'url' =\u003e '/home',\r\n    'text' =\u003e 'Home',\r\n    'target' =\u003e '_blank',\r\n],\r\n``` \r\n- a `dropdown` is an item with the `dropdown` key set to an array of `simple items`, `headers`, or `separators` (string '-'): \r\n```php\r\n[\r\n    'url' =\u003e '/home',\r\n    'text' =\u003e 'Dropdown item',\r\n    'dropdown' =\u003e [\r\n        'Intestazione',\r\n        [\r\n            'url' =\u003e '/home',\r\n            'text' =\u003e 'Home',\r\n            'target' =\u003e '_blank',\r\n        ],\r\n        '-',\r\n        [\r\n            'url' =\u003e '/about',\r\n            'text' =\u003e 'About',\r\n        ],\r\n],\r\n```\r\n- a `megamenu` is an item with the `megamenu` key set to bi-dimensional array of `simple items`, `headers`, or `separators` (string '-'):\r\n```php\r\n[\r\n    'text' =\u003e 'Megamenu item',\r\n    'megamenu' =\u003e [\r\n        [\r\n            'Heading 1',\r\n            [\r\n                'url' =\u003e '/home',\r\n                'text' =\u003e 'Home',\r\n                'target' =\u003e '_blank',\r\n            ],\r\n            '-',\r\n            [\r\n                'url' =\u003e '/about',\r\n                'text' =\u003e 'About',\r\n            ],\r\n        ],\r\n        [\r\n        'Heading 2',\r\n            [\r\n                'url' =\u003e '/a',\r\n                'text' =\u003e 'Link a',\r\n            ],\r\n            '-',\r\n            [\r\n                'url' =\u003e '/b',\r\n                'text' =\u003e 'Link b',\r\n            ],\r\n        ],\r\n    ]\r\n],\r\n```            \r\n\r\nFor each of the previous, with a single string, you specify a menu header item to separate the items.\r\nWith an array, you specify a menu item. `text` and `url` or `route` are required attributes.\r\n\r\n\r\nUse the `can` option if you want conditionally show the menu item. This integrates with Laravel's `Gate` functionality. \r\n\r\n```php\r\n[\r\n    [\r\n        'text' =\u003e 'Create request',\r\n        'url' =\u003e 'request/new',\r\n        'can' =\u003e 'create-request'\r\n    ],\r\n]\r\n```\r\n\r\n#### Custom Menu Filters\r\n\r\nIf you need custom filters, you can easily add your own menu filters to this package. This can be useful when you are \r\nusing a third-party package for authorization (instead of Laravel's `Gate` functionality).\r\n\r\nFor example with Laratrust:\r\n\r\n```php\r\n\u003c?php\r\n\r\nnamespace MyApp;\r\n\r\nuse italia\\DesignLaravelTheme\\Menu\\Builder;\r\nuse italia\\DesignLaravelTheme\\Menu\\Filters\\FilterInterface;\r\nuse Laratrust;\r\n\r\nclass MyMenuFilter implements FilterInterface\r\n{\r\n    public function transform($item, Builder $builder)\r\n    {\r\n        if (isset($item['permission']) \u0026\u0026 ! Laratrust::can($item['permission'])) {\r\n            return false;\r\n        }\r\n\r\n        return $item;\r\n    }\r\n}\r\n```\r\n\r\nAnd then add to `config/bootstrap-italia.php`:\r\n\r\n```php\r\n'filters' =\u003e [\r\n    italia\\DesignLaravelTheme\\Menu\\Filters\\HrefFilter::class,\r\n    italia\\DesignLaravelTheme\\Menu\\Filters\\ActiveFilter::class,\r\n    //italia\\DesignLaravelTheme\\Menu\\Filters\\GateFilter::class, Comment this line out\r\n    MyApp\\MyMenuFilter::class,\r\n]\r\n```\r\n\r\n#### Menu configuration at runtime\r\n\r\nIt is also possible to configure the menu at runtime, e.g. in the boot of any service provider.\r\nUse this if your menu is not static, for example when it depends on your database or the locale.\r\nIt is also possible to combine both approaches. The menus will simply be concatenated and the order of service providers\r\ndetermines the order in the menu.\r\n\r\nTo configure the menu at runtime, register a handler or callback for the `MenuBuilding` event, for example in the \r\n`boot()` method of a service provider:\r\n\r\n```php\r\nuse Illuminate\\Contracts\\Events\\Dispatcher;\r\nuse italia\\DesignLaravelTheme\\Events\\BuildingMenu;\r\n\r\nclass AppServiceProvider extends ServiceProvider\r\n{\r\n\r\n    public function boot(Dispatcher $events)\r\n    {\r\n        $events-\u003elisten(BuildingMenu::class, function (BuildingMenu $event) {\r\n            $event-\u003emenu-\u003eadd_slim_header([\r\n                            'text' =\u003e 'Blog',\r\n                            'url' =\u003e 'admin/blog'\r\n                        ]);\r\n            $event-\u003emenu-\u003eadd_header([\r\n                            'text' =\u003e 'Blog',\r\n                            'url' =\u003e 'admin/blog',\r\n                        ]);\r\n        });\r\n    }\r\n\r\n}\r\n```\r\nThe configuration options are the same as in the static configuration files.\r\n\r\nA more practical example that actually uses the database:\r\n\r\n```php\r\n    public function boot(Dispatcher $events)\r\n    {\r\n        $events-\u003elisten(BuildingMenu::class, function (BuildingMenu $event) {            \r\n\r\n            $items = Page::all()-\u003emap(function (Page $page) {\r\n                return [\r\n                    'text' =\u003e $page['title'],\r\n                    'url' =\u003e route('admin.pages.edit', $page)\r\n                ];\r\n            });\r\n\r\n            $event-\u003emenu-\u003eadd_slim_header(...$items);\r\n        });\r\n    }\r\n```\r\n\r\nThis event-based approach is used to make sure that your code that builds the menu runs only when the page is \r\nactually displayed and not on every request.\r\n\r\n#### Active menu items\r\n\r\nBy default, a menu item is considered active if any of the following holds:\r\n- The current path matches the `url` parameter\r\n- The current path is a sub-path of the `url` parameter\r\n- If it has a submenu containing an active menu item\r\n\r\nTo override this behavior, you can specify an `active` parameter with an array of active URLs, asterisks and regular \r\nexpressions are supported. Example:\r\n\r\n```php\r\n[\r\n    'text' =\u003e 'Pages'\r\n    'url' =\u003e 'pages',\r\n    'active' =\u003e ['pages', 'content', 'content/*']\r\n]\r\n```\r\n\r\n\r\n\r\n## 5. Translations\r\n\r\nAt the moment, Italian and English translations are available out of the box.\r\nJust specifiy the language in `config/app.php`.\r\nIf you need to modify the texts or add other languages, you can publish the language files:\r\n\r\n```\r\nphp artisan vendor:publish --provider=\"italia\\DesignLaravelTheme\\ServiceProvider\" --tag=translations\r\n```\r\n\r\nNow, you can edit translations or add languages in `resources/lang/vendor/bootstrap-italia`.\r\n\r\n## 6. Customize views\r\n\r\nIf you need full control over the provided views, you can publish them:\r\n\r\n```\r\nphp artisan vendor:publish --provider=\"italia\\DesignLaravelTheme\\ServiceProvider\" --tag=views\r\n```\r\n\r\nNow, you can edit the views in `resources/views/vendor/bootstrap-italia`.\r\n\r\n## 7. Issues, Questions and Pull Requests\r\n\r\nYou can report issues and ask questions in the [issues section](https://github.com/italia/DesignLaravelTheme/issues). Please start your issue with `ISSUE: ` and your question with `QUESTION: `\r\n\r\nIf you have a question, check the closed issues first. Over time, I've been able to answer quite a few.\r\n\r\nTo submit a Pull Request, please fork this repository, create a new branch and commit your new/updated code in there. Then open a Pull Request from your new branch. Refer to [this guide](https://help.github.com/articles/about-pull-requests/) for more info.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitalia%2Fdesign-laravel-theme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitalia%2Fdesign-laravel-theme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitalia%2Fdesign-laravel-theme/lists"}