Simplify layout and component management in your HydePHP projects.
HydePHP Layouts Manager is a powerful package designed to simplify the management of layouts and reusable components in your HydePHP projects. It provides an intuitive way to organize and customize themes, layouts, and components, enhancing your workflow while keeping your codebase clean and maintainable.
Check it out: HydePHP Layouts Manager
-
Dynamic Layout Management: Easily switch and manage layouts across your HydePHP site.
-
Reusable Components: Build modular, customizable components with default attributes.
-
CLI Tools: Automate common tasks like listing layouts and merging configuration files.
-
Built-in Flowbite Support: Includes pre-designed components using the Flowbite library.
-
Customizable Themes: Modify and extend default layouts and styles.
Use Composer to add the package to your project:
composer require melasistema/hyde-layouts-manager
Publish the package's configuration file to your app's config
directory for customization:
php hyde vendor:publish --provider="Melasistema\HydeLayoutsManager\HydeLayoutsManagerServiceProvider" --tag="hyde-layouts-manager-config"
Manually include the Layouts Manager configuration in your tailwind.config.js
file:
const HydeLayoutsManagerConfig = require('./tailwind-layouts-manager.config.js');
module.exports = {
darkMode: 'class',
content: [
'./resources/views/**/*.blade.php',
'./vendor/hyde/framework/resources/views/**/*.blade.php',
...HydeLayoutsManagerConfig.content,
],
theme: {
extend: {
...HydeLayoutsManagerConfig.theme.extend,
},
},
};
Automate the process with the tailwind:merge
command. This replaces your existing tailwind.config.js
file with the default configuration from HydeLayoutsManager.
Run the command:
php hyde tailwind:merge`
The default theme and components shipped with HydeLayoutsManager use Flowbite. You can add these dependencies manually or by using the package-json:merge
command.
Add the following Flowbite dependencies to your package.json
file:
"devDependencies": {
"flowbite": "^2.5.2"
}
Then, install the dependencies:
npm install
Use the package-json:merge
command to automatically merge the Flowbite dependencies into your existing package.json
.
package.json
. Ensure to back it up if you have custom dependencies.
Run the command:
php hyde package-json:merge
Afterward, run:
npm install
Add Flowbite styles and scripts in you webpack.mix.js
file:
let mix = require('laravel-mix');
mix.css('node_modules/flowbite/dist/flowbite.css', 'app.css')
.js('node_modules/flowbite/dist/flowbite.js', 'app.js')
.js('resources/assets/app.js', 'app.js')
.postCss('resources/assets/app.css', 'app.css', [
require('tailwindcss'),
require('autoprefixer'),
])
.setPublicPath('_site/media')
.copyDirectory('_site/media', '_media')
Add dynamic @extends() directive to your pages for the "Theme Switching" es. index.blade.php
:
@php($title = 'Home')
@extends(config('hyde-layouts-manager.layouts.' . config('hyde-layouts-manager.default_layout') . '.app', 'hyde::layouts.app'))
@section('content')
// page content
@endsection
If you want to customize the default views, publish them to your application:
php hyde vendor:publish --provider="Melasistema\HydeLayoutsManager\HydeLayoutsManagerServiceProvider" --tag="hyde-layouts-manager-views"
After completing the installation, youβre ready to build dynamic layouts and reusable components with HydePHP Layouts Manager! π
Edit the default_layout
option in the configuration file:
'default_layout' => 'melasistema', // Or 'hyde' for the default Hyde layout
Layouts are defined in the layouts
section of the configuration file. Each layout can have different views, styles, scripts, and navigation settings:
'layouts' => [
'melasistema' => [
'app' => 'vendor.hyde-layouts-manager.layouts.melasistema.app',
'page' => 'vendor.hyde-layouts-manager.layouts.melasistema.page',
'post' => 'vendor.hyde-layouts-manager.layouts.melasistema.post',
'styles' => 'vendor/hyde-layouts-manager/css/melasistema/app.css',
'scripts' => 'vendor/hyde-layouts-manager/js/melasistema/app.js',
],
],
Below is an example of how your project could be structured after installing the package:
my-hyde-project/
βββ config/
β βββ hyde-layouts-manager.php
βββ resources/
β βββ views/
β βββ vendor/
β βββ hyde-layouts-manager/
β βββ components/
β β βββ hero.blade.php
β βββ layouts/
β βββ melasistema/
β βββ app.blade.php
βββ tailwind-layouts-manager.config.js`
Components are reusable UI elements with configurable defaults. The package provides two ways to use components in your Blade templates.
You can use the Blade @include
directive to render components with default or customized data:
@include('vendor.hyde-layouts-manager.components.hero', [
'title' => 'Welcome to My Site',
'description' => 'This is a customizable hero component.',
])
While this approach is straightforward and supports simple customizations, we encourage using the renderComponent()
method for better flexibility and configuration management.
The renderComponent()
method, provided by the Hyde Layouts Manager
, dynamically renders components with the ability to override default configurations. Here's an example:
{!! app('layout.manager')->renderComponent('hero',
[
'title' => 'Welcome to My Amazing Site',
'description' => 'This hero component is fully customizable.',
'primaryButton' => [
'text' => 'Get Started',
'link' => '/start',
],
])
!!}
This method fetches the component configuration from the hyde-layouts-manager.php
configuration file, allowing you to:
- Define defaults for each component.
- Override settings dynamically at runtime.
You can customize default settings for components in the hyde-layouts-manager.php
configuration file under the components
key. For example:
'components' => [
'hero' => [
'view' => 'vendor.hyde-layouts-manager.components.hero',
'default' => [
'bgColor' => 'bg-white',
'darkBgColor' => 'dark:bg-gray-900',
'padding' => 'py-16',
'textColor' => 'text-gray-900',
'darkTextColor' => 'dark:text-white',
'title' => 'HydePHP Layouts Manager',
'description' => 'Manage your layouts and reusable components with ease.',
'align' => 'center',
'primaryButton' => [
'text' => 'Learn More',
'link' => '/learn-more',
'bgColor' => 'bg-blue-700',
'textColor' => 'text-white',
],
'secondaryButton' => [
'text' => 'Get Started',
'link' => '/start',
'bgColor' => 'bg-gray-100',
'textColor' => 'text-indigo-500',
],
],
],
],
- Dynamic Overrides: Easily override defaults for individual component instances.
- Centralized Configuration: Maintain consistent default values in the configuration file.
- Flexibility: Simplifies reusability for components across projects.
By leveraging these methods, you can build scalable and easily customizable layouts with HydeLayoutsManager. π
The package includes several Artisan commands to streamline your workflow:
-
List Layouts: Display available layouts:
php hyde layouts:list
-
Merge Package JSON: Merge dependencies into your
package.json
:php hyde package-json:merge
-
Merge Tailwind Config: Merge Tailwind configurations into your
tailwind.config.js
file:php hyde tailwind:merge
You can add custom layouts by defining them in the layouts
section of the configuration file and placing the corresponding Blade templates in resources/views/vendor/hyde-layouts-manager
.
To customize components, publish the views and edit the files in resources/views/vendor/hyde-layouts-manager/components
.
Customize navigation branding by setting the navigation.brand
options in the configuration file:
'navigation' => [
'brand' => [
'type' => 'image', // options: 'text', 'image', 'custom'
'url' => '/',
'lightLogo' => 'media/hyde-layouts-manager/logo/logo-navigation-light.png',
'darkLogo' => 'media/hyde-layouts-manager/logo/logo-navigation-dark.png',
'logoHeight' => 'h-10',
],
],
This project is made possible by the inspiration, contributions, and tools of an incredible community. A heartfelt thank you to:
-
π¨βπ» Author: Luca Visciola β Passionate developer and creator of Hyde Layouts Manager. Reach out at [email protected] for inquiries or feedback.
-
π Inspired by HydePHP: The foundation of this project stems from the brilliance of Caen De Silva. Discover the magic of static site generation at HydePHP GitHub.
-
π¨ Boosted by Flowbite: This package features beautiful UI components and layouts, made even better with tools from Flowbite.
To the open-source community and all contributorsβyour dedication and collaboration inspire innovation and make tools like
This package is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions! Feel free to open an issue or submit a pull request on GitHub.
If you encounter any issues or have questions, please open an issue on GitHub.