{"id":23489940,"url":"https://github.com/stydenet/html","last_synced_at":"2025-05-14T20:03:20.585Z","repository":{"id":35220095,"uuid":"39479273","full_name":"StydeNet/html","owner":"StydeNet","description":"Laravel package designed to generate common HTML components","archived":false,"fork":false,"pushed_at":"2025-02-23T16:40:14.000Z","size":595,"stargazers_count":266,"open_issues_count":7,"forks_count":87,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-03T02:59:13.816Z","etag":null,"topics":["alert-messages","form-builder","html-builder","laravel","laravel-collective","menu-generator"],"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/StydeNet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["sileence"],"patreon":"duiliopalacios","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2015-07-22T01:45:34.000Z","updated_at":"2025-04-02T21:02:11.000Z","dependencies_parsed_at":"2024-12-25T00:12:57.292Z","dependency_job_id":"61a06469-a55c-4c91-b69a-d00598f3064d","html_url":"https://github.com/StydeNet/html","commit_stats":{"total_commits":134,"total_committers":22,"mean_commits":6.090909090909091,"dds":0.7761194029850746,"last_synced_commit":"3f5ae834d88193cf9bccef678f0642a600996d94"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fhtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fhtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fhtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StydeNet%2Fhtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StydeNet","download_url":"https://codeload.github.com/StydeNet/html/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161255,"owners_count":21057553,"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":["alert-messages","form-builder","html-builder","laravel","laravel-collective","menu-generator"],"created_at":"2024-12-25T00:12:47.256Z","updated_at":"2025-04-10T04:53:56.060Z","avatar_url":"https://github.com/StydeNet.png","language":"PHP","readme":"# StydeNet Html package\n\n[![Build Status](https://travis-ci.org/StydeNet/html.svg?branch=master)](https://travis-ci.org/StydeNet/html)\n[![Downloads](https://img.shields.io/packagist/dt/styde/html.svg)](https://packagist.org/packages/styde/html)\n[![Version](https://img.shields.io/packagist/v/styde/html.svg)](https://packagist.org/packages/styde/html)\n[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md)\n\nThis package contains a collection of Laravel PHP classes designed to generate common HTML components, such as:\n\n* Menus\n* Alert messages\n* Form fields\n* Collection of radios and checkboxes\n\nThis is an extension of the Laravel Collective [HTML package](https://github.com/laravelcollective/html) and will be very useful if you are working on a custom CMS, an admin panel or basically any project that needs to generate HTML dynamically.\n\n## How to install\n\n1. The preferred way to install this package is through Composer:\n\n**Laravel 6.0 users / Laravel 7.0 users**:\n\nInstall by running `composer require \"styde/html=~1.8\"` or adding `\"styde/html\": \"~1.8\"` to your `composer.json` file and then running `composer update`.\n\n**Laravel 5.8 users**:\n\nInstall by running `composer require \"styde/html=~1.7\"` or adding `\"styde/html\": \"~1.7\"` to your `composer.json` file and then running `composer update`.\n\n**Laravel 5.7 users**:\n\nInstall by running `composer require \"styde/html=~1.6\"` or adding `\"styde/html\": \"~1.6\"` to your `composer.json` file and then running `composer update`.\n\n**Laravel 5.6 users**:\n\nInstall by running `composer require \"styde/html=~1.5\"` or adding `\"styde/html\": \"~1.5\"` to your `composer.json` file and then running `composer update`.\n\n**Laravel 5.5 users**:\n\nInstall by running `composer require \"styde/html=~1.4\"` or adding `\"styde/html\": \"~1.4\"` to your `composer.json` file and then running `composer update`.\n\n2. Next, add the new provider to the `providers` array in `config/app.php` (this step is not necessary if you are using Laravel 5.5 with package auto-discovery)\n\n```php\n'providers' =\u003e [\n    // ...\n    Styde\\Html\\HtmlServiceProvider::class,\n    // ...\n],\n```\n\n3. Also, you need to register in the `app/Http/Kernel.php` file the `\\Styde\\Html\\Alert\\Middleware::class` middleware **BEFORE** the `EncryptCookies` middleware, for Laravel 5.8 and later the middleware needs to be registered **AFTER** the `StartSession` middleware. For Laravel 5.4 and later, it's in the `$middlewareGroups` array and for previous versions (Laravel 5.3, 5.2, 5.1) it's in the `$middleware` array:\n\n```php\n// For Laravel 5.4 and later\nprotected $middlewareGroups = [\n    // For Laravel 5.8 and later this needs to be after the StartSession middleware\n    \\Styde\\Html\\Alert\\Middleware::class,\n    //...\n];\n\n// For Laravel 5.3, 5.2, 5.1\nprotected $middleware = [\n    //...\n    \\Styde\\Html\\Alert\\Middleware::class,\n    //...\n];\n```\n\nThis middleware is needed to make the alert messages persistent between sessions, after each request is completed.\n\nPlease notice that the following global aliases will be automatically available (you don't need to add them):\n\n```php\nAlert =\u003e Styde\\Html\\Facades\\Alert\nField =\u003e Styde\\Html\\Facades\\Field\nMenu  =\u003e Styde\\Html\\Facades\\Menu\nForm  =\u003e Collective\\Html\\FormFacade\nHtml  =\u003e Collective\\Html\\HtmlFacade\n```\n\nIf you plan to use the _Access Handler_ as a standalone class, you will need to add the following alias:\n\n```php\n'aliases' =\u003e [\n    // ...\n    'Access' =\u003e Styde\\Html\\Facades\\Access::class,\n    // ...\n],\n```\n\nOptionally, you may also run `php artisan vendor:publish --provider='Styde\\Html\\HtmlServiceProvider'` to publish the configuration file in `config/html.php` and review its options and values.\n\n## Usage\n\nSince this package is largely using [LaravelCollective/Html](https://github.com/laravelcollective/html), its documentation for forms and fields is applicable to this package.\n\n## Sandbox\n\n[![Build Status](https://travis-ci.org/StydeNet/html-integration-tests.svg)](https://travis-ci.org/StydeNet/html-integration-tests)\n\nThis package aims to stay well documented and unit tested; however, there is another repository that includes integration tests and several routes, so you can clone it to watch the components of this package in action in your browser or run the included integration tests. \n\n[Check out the sandbox repository](https://github.com/StydeNet/html-integration-tests)\n\nYou can review those examples and tests as another way to learn more about what you can do with this component, besides reading the documentation.\n\n## Configuration\n\nThis package was created with configuration in mind, if you haven't used this component before, you can simply run:\n\n```zsh\nphp artisan vendor:publish --provider='Styde\\Html\\HtmlServiceProvider'\n```\n\nthis will publish all the configuration options to: `config/html.php` file, where you can explore and read the comments to learn more about the configuration options and their values.\n    \n*Note:* Since the default configuration will be merged with the custom configuration, you don't need to publish the entire configuration in every project; instead, just set the values you need to override.  \n\nRead this documentation to learn more about the different configuration options this package provides.\n\n## Form Field builder\n\nThe Field Builder will allow you to render the full dynamic markup you need for each form field with only one line of code.\n\nIf you have used the Laravel Collective HTML component before, you already know the basics, simply replace the alias “Form” with “Field”, for example, replace:\n\n```blade\n{!! Form::text('name', 'value', $attributes) !!}\n```\n\nWith this:\n\n```blade\n{!! Field::text('name', 'value', $attributes) !!}\n```\n\n[Learn more about the field builder](docs/field-builder.md)\n\n## Forms\n\nThis package adds the following functionality to the Laravel Collective's Form Builder:\n\n#### novalidate\n\nDeactivate the HTML5 validation, ideal for local or development environments\n\n```php\n//config/html.php\nreturn [\n    'novalidate' =\u003e true\n];\n```\n\n#### radios\n\nGenerate a collection of radios:\ni.e.:\n```blade\n{!! Form::radios('status', ['a' =\u003e 'Active', 'i' =\u003e 'Inactive']) !!}\n```\n\n#### checkboxes\n\nGenerate a collection of checkboxes\n\n```php\n$options = [\n    'php' =\u003e 'PHP',\n    'js' =\u003e 'JS'\n];\n$checked = ['php'];\n```\n\n```blade\n{!! Form::checkboxes('tags', $options, $checked) !!}\n```\n\n[Learn more about the form builder](docs/form-builder.md)\n\n## Alert messages\n\nThis component will allow you to generate complex alert messages.\n\n```php\nAlert::info('Your account is about to expire')\n    -\u003edetails('Renew now to learn about:')\n    -\u003eitems(['Laravel', 'PHP', 'And more!'])\n    -\u003ebutton('Renew now!', url('renew'), 'primary');\n```\n\n```blade\n{!! Alert::render() !!}\n```\n\n[Learn more about the alert component](docs/alert-messages.md)\n\n## Menu generator\n\nMenus are not static elements, sometimes you need to mark the current section, translate items, generate dynamic URLs or show/hide options for certain users.\n\nSo instead of adding a lot of HTML and Blade boilerplate code, you can use this component to generate dynamic menus styled for your preferred CSS framework.\n\nTo generate a menu simply add the following code in your layout’s template:\n\n```blade\n{!! Menu::make('items.here') !!}\n```\n\n[Learn more about the menu generator](docs/menu-generator.md)\n\n## HTML builder\n\nThis package extends the functionality of the Laravel Collective’s HTML Builder.\n\nThere’s only one extra method _for now_, but it’s very useful!\n\n#### Generate CSS classes:\n\n```blade\n{!! Html::classes(['home' =\u003e true, 'main', 'dont-use-this' =\u003e false]) !!}\n```\n\nReturns: `class=\"home main\"`\n\n[Learn more about the HTML builder](docs/html-builder.md)\n\n### Helpers\n\nIn addition of using the facade methods `Alert::message` and `Menu::make`, you can use:\n\n```php\nalert('this is the message', 'type-of-message')\n```\n\n```php\nmenu($items, $classes)\n```\n\n## Access handler\n\nSometimes you want to show or hide certain menu items, form fields, etc. for certain users, with this component you can do it without the need of conditionals or too much extra boilerplate code, just pass one of the following options as a field attribute or menu item value.\n\n1. callback: a function that should return true if access is granted, false otherwise.\n2. logged: true: requires authenticated user, false: requires guest user.\n3. roles: true if the user belongs to any of the required roles.\n\ni.e.: \n\n```blade\n{!! Field::select('user_id', null, ['roles' =\u003e 'admin']) !!}\n```\n\n[Learn more about the access handler](docs/access-handler.md)\n\n## Themes\n\nThere are a lot of CSS frameworks out there, this package was created with that in mind, and even though *Bootstrap* (version 3 and 4) and *Bulma* are included out of the box, we plan to add more packages in the future (we also invite you to collaborate).\n\nBut you can also create your own themes with ease, or modify the existing one:\n\nTo change and / or customize the theme, simply run: \n\n```zsh\nphp artisan vendor:publish\n```\n\nThen go to `config/html.php` and change the theme value:\n\n```php\n//config/html.php\nreturn [\n    'theme' =\u003e 'your-theme-here'\n];\n```\n\nYou can edit and/or create new templates in `resources/views/themes/` \n\n[Learn more about the themes](docs/themes.md)\n\n## Internationalization\n\nThis package was also created with internationalization in mind.\n\nIf you don’t plan to use this feature, you can deactivate translations in the configuration\n\n```php\n//config/html.php\nreturn [\n    //…\n    'translate_texts' =\u003e false\n    //…\n];\n```\n\nBut if your project needs to implement more than one language or you want to organize all the texts in `resources/lang/` instead of hard coding them in the controllers, views, etc. set `'translate_texts'` to `true`.\n\n[Learn more about the internationalization](docs/internationalization.md)\n\n## More documentation\n\nYou can find a lot of comments if you dig into the source code, as well as unit tests in the spec/ directory, you can also clone the [integration tests repository](https://github.com/StydeNet/html-integration-tests).\n\nIf you have additional questions, feel free to contact me on Twitter ([@Sileence](https://twitter.com/sileence)) or send me an email to [admin@styde.net](mailto:admin@styde.net).\n\n## License\n\nThe Styde\\Html package is open-sourced software licensed under the MIT license.\n","funding_links":["https://github.com/sponsors/sileence","https://patreon.com/duiliopalacios"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstydenet%2Fhtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstydenet%2Fhtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstydenet%2Fhtml/lists"}