{"id":20216445,"url":"https://github.com/karlomikus/theme","last_synced_at":"2025-04-10T15:12:29.790Z","repository":{"id":57004546,"uuid":"44624252","full_name":"karlomikus/theme","owner":"karlomikus","description":"Add theming support to your Laravel 5.* projects","archived":false,"fork":false,"pushed_at":"2019-05-12T16:19:43.000Z","size":39,"stargazers_count":69,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T13:11:16.728Z","etag":null,"topics":["laravel","php","theme"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karlomikus.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-20T17:47:05.000Z","updated_at":"2025-02-11T21:32:12.000Z","dependencies_parsed_at":"2022-08-21T13:50:51.700Z","dependency_job_id":null,"html_url":"https://github.com/karlomikus/theme","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlomikus%2Ftheme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlomikus%2Ftheme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlomikus%2Ftheme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlomikus%2Ftheme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karlomikus","download_url":"https://codeload.github.com/karlomikus/theme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247749966,"owners_count":20989714,"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":["laravel","php","theme"],"created_at":"2024-11-14T06:28:08.602Z","updated_at":"2025-04-10T15:12:29.772Z","avatar_url":"https://github.com/karlomikus.png","language":"PHP","funding_links":[],"categories":["Packages"],"sub_categories":["Views"],"readme":"# Laravel Theme\n\n[![Build Status](https://travis-ci.org/karlomikus/theme.svg?branch=master)](https://travis-ci.org/karlomikus/theme)\n[![Latest Stable Version](https://poser.pugx.org/karlomikus/theme/v/stable)](https://packagist.org/packages/karlomikus/theme)\n[![License](https://poser.pugx.org/karlomikus/theme/license)](https://packagist.org/packages/karlomikus/theme)\n\nAdd theming support to your Laravel 5.* projects.\n\n### Features\n\n- Custom theme locations\n- Support for theme inheritence with theme fallback\n- Theme assets loading\n- Artisan console commands\n\n## Install\n\nRequire it via terminal like so:\n``` bash\n$ composer require karlomikus/theme\n```\n\nOr add the package to your composer file:\n\n``` json\n\"karlomikus/theme\": \"1.*\"\n```\n\nNext add new service provider and facade to your `config/app.php` file:\n\n``` php\n// Service provider\nKarlomikus\\Theme\\ThemeServiceProvider::class\n// Facade\n'Theme' =\u003e Karlomikus\\Theme\\Facade\\Theme::class\n```\n\nNext you need to publish the config file:\n\n``` bash\n$ php artisan vendor:publish\n```\n\nThis will create a theme.php file in your config directory in which you can define your default path to themes directory.\n\n## Theme setup\n\nCreate new folder in your themes directory (default: public/themes) and add views folder (which will hold all your custom views)\nand theme.json file (contains information about a theme).\n\n``` json\n{\n    \"name\": \"Theme name\",\n    \"author\": \"Karlo Mikuš\",\n    \"description\": \"Default theme description\",\n    \"version\": \"1.0\",\n    \"namespace\": \"theme-folder\",\n    \"parent\": null\n}\n```\n\nThis are all available attributes, but the required ones only include: `name`, `author` and `namespace`.\nValue of `namespace` must be the name of the theme's folder.\n\nIf you want your theme to depend on other theme views, just include a parent theme namespace in `parent` attribute.\n\nExample folder structure:\n\n```\n- public/\n    - themes/\n        - theme-1/\n            - views/\n            - theme.json\n```\n\n## Usage\n\nThe library will firstly check all available valid themes in theme directory.\n\nYou can then set a theme by it's namespace:\n\n``` php\nTheme::set('theme-namespace');\n```\n\nThen you call views like you usually do in laravel:\n\n``` php\nview('home');\n```\n\nThis will firstly check if there is a home.blade.php in current theme directory.\nIf none is found then it checks parent theme, and finally falls back to default laravel views location.\n\nYou can also inject theme instance using ThemeInterface.\n\n``` php\nuse Karlomikus\\Theme\\Contracts\\ThemeInterface;\n\nprivate $theme;\n\npublic function __construct(ThemeInterface $theme)\n{\n    $this-\u003etheme = $theme\n}\n```\n\n### Theme path\n\nYou can set default path to themes folder in config/theme.php file. Please note that currently themes folder must be somewhere inside public folder.\n\n## Available methods\n\nHere's the list of methods you can access:\n\n``` php\n// Activate/set theme\nTheme::set('theme-namespace');\n\n// Get all available themes as an array\nTheme::all();\n\n// Get currently active\nTheme::get();\n\n// Get theme by namespace\nTheme::get('specific-namespace');\n\n// Override default theme path\nTheme::setDefaultThemePath('new/path/to/themes');\n\n// Check if theme exists\nTheme::has('theme-namespace');\n\n// Render theme path URL\ntheme_url('assets/style.css');\n```\n\n### Artisan commands\n\nGet a table of all found themes:\n``` bash\n$ php artisan theme:list\n\n+------------------+-------------+------------+\n| Name             | Author      | Namespace  |\n+------------------+-------------+------------+\n| Bootstrap theme  | Karlo Mikus | bootstrap  |\n| Default theme    | Test Author | default    |\n| Foundation theme | Lorem Ipsum | foundation |\n| Test theme       | Dolor Sitha | test       |\n+------------------+-------------+------------+\n```\n\nCreate a theme directory with config file:\n``` bash\n$ php artisan theme:make\n\n Template name:\n \u003e Theme name\n\n Template author:\n \u003e Firstn Lastn\n\nTheme created succesfully!\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## TODO\n\n- Contact me for ideas","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarlomikus%2Ftheme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarlomikus%2Ftheme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarlomikus%2Ftheme/lists"}