HydePHP Documentation
repository·2.x·Indexed 19 days ago
https://github.com/hydephp/hydeA Laravel-powered static site generator for building blogs, documentation, and websites using Markdown or Blade templates. Features a built-in TailwindCSS frontend, Vite-based asset management, and a CLI for content scaffolding. Includes comprehensive migration guides for upgrading to v2.0, covering dependency updates, the transition from Laravel Mix to Vite, and API changes to the Routes, Asset, and Includes facades.
What's inside HydePHP
- All frontend components and page layouts in HydePHP are built using Laravel Blade. To customize them, you can publish the vendor views to your project, allowing you to override the default templates just as you would in a standard Laravel application.
Customize TailwindCSS styles
2.xHydePHP comes with precompiled and minified TailwindCSS styles in
app.cssand uses HydeFront to serve assets via CDN.If you need to customize the Tailwind configuration or add new Tailwind classes via Blade files, you must recompile the styles using the included Vite setup by running:
npm run buildInstall HydePHP via Composer
2.xTo create a new HydePHP project, use the
composer create-projectcommand. This scaffolds a new directory with the HydePHP structure and dependencies.composer create-project hyde/hydeCreate and manage content in HydePHP
2.xHydePHP uses specific directories to organize different types of content. You can place files directly into these folders or use the
hyde:makeCLI commands to scaffold them with appropriate front matter or layouts._posts: For blog posts (typically Markdown with Front Matter)._docs: For documentation pages (plain Markdown)._pages: For simple Markdown pages or advanced Laravel Blade files.
Migrate from Laravel Mix to Vite
2.xHydePHP v2.0 uses Vite instead of Laravel Mix for asset management.
- Remove Mix: Delete
webpack.mix.jsfrom your project root. - Create Vite Config: Create
vite.config.jsin your project root. - Update CSS: Update
resources/assets/app.cssto use the new Tailwind v4@importsyntax. - Upgrade Tailwind: Run the automated tool to convert your Tailwind configuration to v4.
Vite Configuration Example:
import { defineConfig } from 'vite'; import tailwindcss from "@tailwindcss/vite"; import hyde from 'hyde-vite-plugin'; export default defineConfig({ plugins: [ hyde({ input: ['resources/assets/app.css', 'resources/assets/app.js'], watch: ['_pages', '_posts', '_docs'], refresh: true, }), tailwindcss(), ], });New CSS Import Pattern:
@import 'hydefront/components/torchlight.css' layer(base); @import 'tailwindcss'; @config '../../tailwind.config.js';npx @tailwindcss/upgrade- Remove Mix: Delete
Upgrade to HydePHP v2.0
2.xHydePHP v2.0 is a major evolution that replaces Laravel Mix with Vite, rewrites the navigation system, and upgrades to Tailwind CSS v4.
Prerequisites
- Ensure you are running HydePHP v1.6 or later (v1.8 is recommended).
- Backup your project by committing all changes to Git or creating a directory backup.
High-level Upgrade Steps
- Update Dependencies: Update
composer.jsonandpackage.json. - Migrate Frontend: Replace Laravel Mix with Vite and upgrade to Tailwind CSS v4.
- Update Configuration: Modify
config/hyde.php,config/docs.php, andapp/config.phpto match new schemas. - Update Code: Adjust usage of
Routes,Asset,Includes, andDataCollection. - Rebuild: Clear caches and run the new build commands.
# Recommended pre-upgrade backup git init git add . git commit -m "Pre-upgrade backup before HydePHP v2.0"Update Composer and Node Dependencies for v2.0
2.xUpdate your dependency files to support the new framework version and Vite-based asset pipeline.
Composer Update
Update
composer.jsonwith the following requirements:php:^8.2hyde/framework:^2.0laravel-zero/framework:^11.0hyde/realtime-compiler:^4.0(dev)
Then run:
composer updateNode/NPM Update
Replace the
devDependenciesinpackage.jsonwith the Vite-compatible set and add"type": "module"to the top level of the file. Update your scripts to use Vite.New Scripts:
"scripts": { "dev": "vite", "build": "vite build" }Then run:
npm install{ "type": "module", "require": { "php": "^8.2", "hyde/framework": "^2.0", "laravel-zero/framework": "^11.0" }, "require-dev": { "hyde/realtime-compiler": "^4.0" }, "devDependencies": { "@tailwindcss/typography": "^0.5.0", "@tailwindcss/vite": "^4.1.0", "autoprefixer": "^10.4.0", "hyde-vite-plugin": "^1.1.0", "hydefront": "^4.0.0", "postcss": "^8.5.0", "tailwindcss": "^4.1.0", "vite": "^7.1.0" } }Build your static site
2.xOnce your content is ready, run the
buildcommand. HydePHP will compile your Markdown and Blade files into static HTML files, which are saved in the_sitedirectory.php hyde buildUpdate Documentation Configuration (config/docs.php)
2.xThe sidebar and table of contents configuration in
config/docs.phphas been reorganized into a singlesidebarkey.New Structure:
'sidebar' => [ 'order' => [ 'readme', 'installation', ], 'labels' => [ // ... ], 'table_of_contents' => [ 'enabled' => true, 'min_heading_level' => 2, 'max_heading_level' => 4, ], ],Update HydePHP Configuration (config/hyde.php)
2.xSeveral keys and formats in
config/hyde.phphave changed in v2.0.Features (Enums)
Replace method calls with Enum values.
- Old:
Features::htmlPages() - New:
Feature::HtmlPages
Navigation
Navigation items must now be an array of objects or use the
Navigationfacade.- Old:
'Custom Item' => '/custom-page' - New:
['label' => 'Custom Item', 'destination' => '/custom-page'] - Facade:
Navigation::item('url', 'label', status_code)
Other Key Changes
- Subdirectory Display: Rename
subdirectoriestosubdirectory_display. - Cache Busting: Rename
enable_cache_bustingtocache_busting. - Authors: The format is now an associative array keyed by username.
- HydeFront: Remove
hydefront_versionandhydefront_cdn_url(now automatic).
New Author Format:
'authors' => [ 'username' => Author::create( name: 'Display Name', website: 'https://example.com', bio: 'Author bio', avatar: 'avatar.png', socials: ['twitter' => '@username'] ), ],- Old:
Update Application Configuration (app/config.php)
2.xIn
app/config.php, you must register the new Navigation service provider and update aliases.Providers: Add
Hyde\Foundation\Providers\NavigationServiceProvider::class,to the'providers'array.Aliases: Add the following to the
'aliases'array:'Vite' => \Hyde\Facades\Vite::class,'MediaFile' => \Hyde\Support\Filesystem\MediaFile::class,
Troubleshoot asset compilation issues
2.xIf your assets are failing to compile after an upgrade, follow these steps to reset your environment:
- Delete
node_modulesandpackage-lock.json. - Run
npm installto reinstall dependencies. - Clear the
_mediadirectory. - Run
npm run buildto attempt a fresh compilation.
rm -rf node_modules package-lock.json npm install rm -rf _media npm run build- Delete