### Update Routes Facade API (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Changes the methods used to retrieve routes from the Routes facade. `get` now throws an exception if the route is not found (similar to `getOrFail`), and `getOrFail` is replaced by `find` which returns null if not found. ```php $route = Routes::get('route-name'); // Returns null if not found $route = Routes::getOrFail('route-name'); // Throws exception ``` ```php $route = Routes::find('route-name'); // Returns null if not found $route = Routes::get('route-name'); // Throws exception ``` -------------------------------- ### Add Navigation Service Provider and Aliases (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Instructs to add the `NavigationServiceProvider` to the application's service providers and register `Vite` and `MediaFile` facades in the aliases array within `app/config.php`. ```php Hyde\Foundation\Providers\NavigationServiceProvider::class, ``` ```php 'Vite' => \Hyde\Facades\Vite::class, 'MediaFile' => \Hyde\Support\Filesystem\MediaFile::class, ``` -------------------------------- ### Create a Documentation Page (Markdown) Source: https://context7.com/hydephp/hyde/llms.txt This Markdown file illustrates creating a documentation page with minimal YAML front matter for navigation priority and labels. The content is structured using Markdown headings and includes code blocks for shell commands and PHP configuration examples. It also provides internal links to other documentation sections. ```markdown --- navigation.priority: 10 navigation.label: "Installation Guide" --- # Installation Guide ## Requirements - PHP 8.2 or higher - Composer - Node.js (optional, for asset compilation) ## Quick Install ```bash # Create new project composer create-project hyde/hyde my-docs # Navigate to directory cd my-docs # Start development server php hyde serve ``` ## Configuration Edit `config/hyde.php` to customize your site: ```php return [ 'name' => 'My Documentation', 'url' => 'https://docs.example.com', ]; ``` ## Next Steps - [Getting Started](getting-started) - [Configuration](configuration) - [Deployment](deployment) ``` -------------------------------- ### Rebuild Site Commands (Bash) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Lists the commands required to rebuild the site after configuration updates. This includes `npm run build` for frontend assets, `php hyde build` for the site, and `php hyde serve` for local development. ```bash npm run build # Build your site php hyde build # Or use the realtime compiler for development php hyde serve ``` -------------------------------- ### Update Asset API Return Types (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Notes that asset methods in HydePHP now return `MediaFile` instances instead of raw strings. Several method names have been updated for clarity, including `asset` (formerly `mediaLink`), `get` (formerly `mediaLink`), `exists` (formerly `hasMediaFile`), `cdnLink`, and `sourcePath` (formerly `mediaPath`). ```php // Methods renamed for clarity Hyde::asset('image.png'); // Previously: Hyde::mediaLink() Asset::get('image.png'); // Previously: Asset::mediaLink() Asset::exists('image.png'); // Previously: Asset::hasMediaFile() HydeFront::cdnLink('app.css'); // Previously: Asset::cdnLink() MediaFile::sourcePath('image.png') // Previously: Hyde::mediaPath() ``` -------------------------------- ### Create Custom Build Script with HydePHP API Source: https://context7.com/hydephp/hyde/llms.txt This PHP script demonstrates how to use HydePHP's internal API to create a custom build process. It shows how to initialize the Hyde application, retrieve all pages, filter pages by type (e.g., MarkdownPost, DocumentationPage), and then use `StaticPageBuilder` to build them. Requires Composer and HydePHP installation. ```php filter(fn($page) => $page instanceof MarkdownPost); foreach ($posts as $page) { echo "Building post: {$page->title}\n"; StaticPageBuilder::handle($page); } // Build documentation pages $docs = $pages->filter(fn($page) => $page instanceof DocumentationPage); foreach ($docs as $page) { echo "Building doc: {$page->title}\n"; StaticPageBuilder::handle($page); } echo "Build complete!\n"; ``` -------------------------------- ### Remove Deprecated HydeFront Settings (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Removes deprecated configuration options related to HydeFront ('hydefront_version' and 'hydefront_cdn_url') as these are now handled automatically by the system. ```php 'hydefront_version' => ..., 'hydefront_cdn_url' => ..., ``` -------------------------------- ### Update `config/docs.php` Sidebar Configuration (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Reorganizes the sidebar configuration within `config/docs.php`. The 'sidebar_order' and 'sidebar_group_labels' are now nested under a 'sidebar' key, and 'table_of_contents' includes new options for 'min_heading_level' and 'max_heading_level'. ```php 'sidebar_order' => [ 'readme', 'installation', ], 'table_of_contents' => [ 'enabled' => true, ], 'sidebar_group_labels' => [ // ... ], ``` ```php 'sidebar' => [ 'order' => [ 'readme', 'installation', ], 'labels' => [ // ... ], 'table_of_contents' => [ 'enabled' => true, 'min_heading_level' => 2, 'max_heading_level' => 4, ], ], ``` -------------------------------- ### Commit Changes Before HydePHP Upgrade (Bash) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Ensures all current project changes are saved in Git before proceeding with the HydePHP v2.0 upgrade, allowing for easy rollback if necessary. ```bash git init git add . git commit -m "Pre-upgrade backup before HydePHP v2.0" ``` -------------------------------- ### Update Node Dependencies for HydePHP v2.0 (JSON) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Updates the package.json file to reflect the shift from Laravel Mix to Vite for frontend tooling in HydePHP v2.0. It replaces old devDependencies with Vite-compatible packages and updates scripts. ```json { "type": "module", "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" } } ``` ```json { "scripts": { "dev": "vite", "build": "vite build" } } ``` -------------------------------- ### Automate Tailwind CSS Upgrade (Bash) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Executes the official Tailwind CSS upgrade tool to automatically update project configurations and stylesheets for Tailwind CSS v4 compatibility. This simplifies the migration process for breaking changes. ```bash npx @tailwindcss/upgrade ``` -------------------------------- ### Configure Vite for HydePHP v2.0 (JavaScript) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Sets up the vite.config.js file for HydePHP v2.0, integrating the Hyde Vite plugin and Tailwind CSS. This configuration defines input files, watch directories, and enables hot module replacement for development. ```javascript 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(), ], }); ``` -------------------------------- ### Rename DataCollections Class (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md The `DataCollections` class has been renamed to `DataCollection`. This requires updating the `use` statement in any PHP files that reference this class. ```php use Hyde\Support\DataCollections; ``` ```php use Hyde\Support\DataCollection; ``` -------------------------------- ### Update CSS Imports for Vite (CSS) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Modifies the `resources/assets/app.css` file to align with Vite's asset handling and HydePHP v2.0's structure. It changes import paths and integrates Tailwind CSS and configuration. ```css @import 'hydefront/components/torchlight.css' layer(base); @import 'tailwindcss'; @config '../../tailwind.config.js'; ``` -------------------------------- ### Rename Cache Busting Setting (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Renames the configuration setting for cache busting from 'enable_cache_busting' to 'cache_busting'. This is a straightforward key change in the configuration array. ```php 'enable_cache_busting' => true, ``` ```php 'cache_busting' => true, ``` -------------------------------- ### Update HydePHP Feature Configuration (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Refactors the HydePHP configuration file (`config/hyde.php`) to use the new `Feature` enum values instead of the older `Features` class methods for defining enabled features. ```php // Before: // 'features' => [ // Features::htmlPages(), // Features::markdownPosts(), // ], // After: 'features' => [ Feature::HtmlPages, Feature::MarkdownPosts, ], ``` -------------------------------- ### Update Build Commands (Bash) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Modifies build commands for CI/CD pipelines and build scripts. `npm run prod` is replaced by `npm run build`, and `php hyde build --run-prod` is replaced by `php hyde build --vite`. Flags like `--run-dev`, `--run-prod`, and `--run-prettier` are removed. ```bash npm run prod php hyde build --run-prod ``` ```bash npm run build php hyde build --vite ``` -------------------------------- ### Update Navigation Configuration (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Modifies the 'navigation' configuration to adopt a new format for custom items and subdirectory display settings. The 'custom_items' array is replaced with a 'custom' array of associative arrays, and 'subdirectories' is renamed to 'subdirectory_display'. ```php 'navigation' => [ 'custom_items' => [ 'Custom Item' => '/custom-page', ], ], ``` ```php 'navigation' => [ 'custom' => [ ['label' => 'Custom Item', 'destination' => '/custom-page'], ], ], ``` ```php use Hyde\Facades\Navigation; 'navigation' => [ 'custom' => [ Navigation::item('https://github.com/hydephp/hyde', 'GitHub', 200), ], ], ``` ```php 'navigation' => [ 'subdirectories' => 'hidden', ], ``` ```php 'navigation' => [ 'subdirectory_display' => 'hidden', ], ``` -------------------------------- ### Clear Caches and Views (Bash) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Provides commands to clear caches and remove compiled view files. This includes `composer dump-autoload`, `php hyde cache:clear`, and removing `.php` files from the views cache directory. ```bash composer dump-autoload php hyde cache:clear rm app/storage/framework/views/*.php ``` -------------------------------- ### Update Author Configuration Format (PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Changes the format for defining blog post authors in the configuration. The 'authors' array now uses associative keys for each author, allowing for more detailed properties like name, website, bio, avatar, and social links. ```php 'authors' => [ Author::create('username', 'Display Name', 'https://example.com'), ], ``` ```php 'authors' => [ 'username' => Author::create( name: 'Display Name', website: 'https://example.com', bio: 'Author bio', avatar: 'avatar.png', socials: ['twitter' => '@username'] ), ], ``` -------------------------------- ### Update Composer Dependencies for HydePHP v2.0 (JSON) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Modifies the composer.json file to specify the required versions for HydePHP v2.0 and its related packages, along with Laravel Zero v11. This step is crucial for enabling the latest framework features. ```json { "require": { "php": "^8.2", "hyde/framework": "^2.0", "laravel-zero/framework": "^11.0" }, "require-dev": { "hyde/realtime-compiler": "^4.0" } } ``` -------------------------------- ### Update Includes Facade Return Types (Blade/PHP) Source: https://github.com/hydephp/hyde/blob/master/UPGRADE.md Explains that methods from the `Includes` facade now return `HtmlString` objects instead of raw strings, affecting how they are displayed in Blade templates. Output is no longer escaped by default, requiring explicit escaping for user-generated content. ```blade {!! Includes::html('partial') !!} ``` ```blade {{ Includes::html('partial') }} ``` ```blade {{ e(Includes::html('foo')) }} ``` -------------------------------- ### Run HydePHP Development Server CLI Source: https://context7.com/hydephp/hyde/llms.txt Launches a local development server with automatic recompilation and live preview. Allows specifying a custom port and provides a dashboard URL. ```bash # Start development server (default: http://localhost:8080) php hyde serve # Specify custom port php hyde serve --port=3000 # Server output Starting the HydePHP Realtime Compiler! > Server running on http://localhost:8080 > Press Ctrl+C to stop > Dashboard available at http://localhost:8080/dashboard ``` -------------------------------- ### Build Static Site with HydePHP CLI Source: https://context7.com/hydephp/hyde/llms.txt Compiles HydePHP project files into static HTML. Supports basic builds, pretty URLs, and generates sitemaps and RSS feeds. Output is directed to a configured directory (default: _site). ```bash php hyde build # Build with pretty URLs (removes .html extensions) php hyde build --pretty-urls # Build output Building your static site! > Clearing output directory... Done in 0.05s > Building 5 pages... - index.html - posts/hello-world.html - docs/getting-started.html > Copying media files... Done > Generating sitemap.xml... Done > Generating RSS feed... Done Site built successfully in 1.23s! ``` -------------------------------- ### Create a Blog Post with Front Matter (Markdown) Source: https://context7.com/hydephp/hyde/llms.txt This Markdown file demonstrates creating a blog post with YAML front matter. The front matter includes metadata such as title, description, category, author, date, image, and featured status. The body of the post is written in Markdown and can include embedded code snippets in various languages. ```markdown --- title: "Getting Started with HydePHP" description: "Learn how to build static sites with HydePHP" category: "Tutorials" author: john_doe date: 2025-01-15 image: posts/getting-started.jpg featured: true --- # Getting Started with HydePHP Welcome to my tutorial on building static sites with HydePHP! ## Installation First, install HydePHP using Composer: ```bash composer create-project hyde/hyde my-site cd my-site php hyde serve ``` ## Creating Content You can create blog posts easily: ```bash php hyde make:post "My First Post" ``` This will create a new Markdown file with pre-filled front matter. ``` -------------------------------- ### Configure HydePHP Documentation Settings (PHP) Source: https://context7.com/hydephp/hyde/llms.txt This PHP configuration file allows customization of the documentation sidebar, table of contents, search functionality, and GitHub integration. It defines options for header, footer, page order, custom labels, and search exclusions. No external dependencies are required beyond the HydePHP framework. ```php [ 'header' => 'Documentation', 'collapsible' => true, 'footer' => '[Back to home](../)', // Page order in sidebar 'order' => [ 'readme', 'installation', 'getting-started', 'configuration', ], // Custom labels 'labels' => [ 'getting-started' => 'Quick Start', ], // Table of contents 'table_of_contents' => [ 'enabled' => true, 'min_heading_level' => 2, 'max_heading_level' => 4, ], ], // Search settings 'create_search_page' => true, 'exclude_from_search' => ['changelog'], // GitHub integration 'source_file_location_base' => 'https://github.com/user/repo/blob/main', 'edit_source_link_text' => 'Edit on GitHub', ]; ``` -------------------------------- ### Scaffold New Content with HydePHP CLI Source: https://context7.com/hydephp/hyde/llms.txt Creates new Markdown or Blade files for posts, pages, or documentation, pre-filled with front matter and structure. Supports specifying file type (e.g., blade) and content title. ```bash # Create a new blog post php hyde make:post "My First Post" # Output: Created _posts/my-first-post.md # Create a Markdown page php hyde make:page "About Us" # Output: Created _pages/about-us.md # Create a Blade page php hyde make:page "Contact" --type=blade # Output: Created _pages/contact.blade.php # Create a documentation page php hyde make:docs "Installation Guide" # Output: Created _docs/installation-guide.md ``` -------------------------------- ### Publish HydePHP Views and Assets CLI Source: https://context7.com/hydephp/hyde/llms.txt Extracts HydePHP framework views and assets to the project for customization. Supports publishing specific components, all views, or the homepage template. ```bash # Publish homepage template php hyde publish:homepage # Output: Published resources/_pages/index.blade.php # Publish all views php hyde publish:views # Output: Published 24 views to resources/views/vendor/hyde/ # Publish specific component php hyde vendor:publish --tag=hyde-layouts ``` -------------------------------- ### HydePHP Site Configuration (config/hyde.php) Source: https://context7.com/hydephp/hyde/llms.txt Main site settings for HydePHP, controlling appearance, behavior, and features. Includes site name, URL, language, output directory, content sources, feature flags (sitemap, RSS), meta tags, author definitions, and navigation customization. ```php env('SITE_NAME', 'My Awesome Site'), 'url' => env('SITE_URL', 'https://example.com'), 'language' => 'en', // Output settings 'output_directory' => '_site', 'pretty_urls' => true, // Content directories 'source_directories' => [ \Hyde\Pages\MarkdownPost::class => '_posts', \Hyde\Pages\DocumentationPage::class => '_docs', \Hyde\Pages\MarkdownPage::class => '_pages', \Hyde\Pages\BladePage::class => '_pages', ], // Features 'generate_sitemap' => true, 'rss' => [ 'enabled' => true, 'filename' => 'feed.xml', 'description' => 'My Blog RSS Feed', ], // Meta tags 'meta' => [ Meta::name('author', 'John Doe'), Meta::name('description', 'My personal blog about web development'), Meta::property('site_name', 'My Awesome Site'), ], // Blog post authors 'authors' => [ 'john_doe' => Author::create( name: 'John Doe', website: 'https://johndoe.com', ), ], // Navigation menu 'navigation' => [ 'order' => [ 'index' => 0, 'posts' => 10, 'docs/index' => 20, ], 'labels' => [ 'index' => 'Home', 'docs/index' => 'Documentation', ], 'exclude' => ['404'], ], ]; ``` -------------------------------- ### Configure Environment Variables Source: https://context7.com/hydephp/hyde/llms.txt This snippet shows how to set environment-specific configuration options in a `.env` file. It includes common settings for site name, URL, syntax highlighting tokens, and development server parameters. This is a standard practice for managing configuration in many PHP projects. ```bash # .env # Site configuration SITE_NAME="My Awesome Blog" SITE_URL=https://myblog.com # Torchlight.dev syntax highlighting TORCHLIGHT_TOKEN=torch_your_token_here # Development server SERVER_PORT=8080 SERVER_HOST=localhost SERVER_DASHBOARD=true SERVER_LIVE_EDIT=true ``` -------------------------------- ### Configure HydePHP Markdown Settings (PHP) Source: https://context7.com/hydephp/hyde/llms.txt This PHP configuration file customizes Markdown processing, including CommonMark extensions, rendering options, and security settings. It allows enabling HTML and Blade rendering, configuring heading permalinks, and defining CSS prose classes. Dependencies include League CommonMark extensions. ```php [ \League\CommonMark\Extension\GithubFlavoredMarkdownExtension::class, \League\CommonMark\Extension\Attributes\AttributesExtension::class, ], // CommonMark configuration 'config' => [ 'heading_permalink' => [ 'min_heading_level' => 2, 'max_heading_level' => 6, ], ], // Security settings 'allow_html' => false, 'enable_blade' => false, // Allow Blade in Markdown (security risk) // Styling 'prose_classes' => 'prose dark:prose-invert max-w-none', // Heading permalinks 'permalinks' => [ 'pages' => [ \Hyde\Pages\DocumentationPage::class, ], ], ]; ``` -------------------------------- ### Extend HydePHP with Custom Service Provider Source: https://context7.com/hydephp/hyde/llms.txt This PHP code defines a custom service provider for HydePHP, allowing extension of framework functionality. It demonstrates registering custom services and listening to core Hyde events like `BuildingSite` and `SiteBuilt` to execute custom pre-build and post-build tasks, such as image optimization or S3 uploads. Requires HydePHP and Laravel service container. ```php app->singleton('custom.service', function ($app) { return new CustomService(); }); } public function boot(): void { // Listen to build events $this->app['events']->listen(BuildingSite::class, function ($event) { echo "Starting build...\n"; // Pre-build tasks $this->generateCustomPages(); $this->optimizeImages(); }); $this->app['events']->listen(SiteBuilt::class, function ($event) { echo "Build complete!\n"; // Post-build tasks $this->generateSearchIndex(); $this->uploadToS3(); }); } protected function generateCustomPages(): void { // Custom page generation logic } protected function optimizeImages(): void { // Image optimization logic } protected function generateSearchIndex(): void { // Search index generation logic } protected function uploadToS3(): void { // S3 upload logic } } ``` -------------------------------- ### Export HydePHP Routes to JSON Source: https://context7.com/hydephp/hyde/llms.txt This script demonstrates how to retrieve all defined routes in a HydePHP project and export their key, output path, page type, and title to a JSON file named 'routes.json'. It requires the HydePHP autoloader and uses the Routes facade for accessing route information. The output is a pretty-printed JSON array of route objects. ```php map(function ($route) { return [ 'key' => $route->getRouteKey(), 'path' => $route->getOutputPath(), 'type' => class_basename($route->getPageClass()), 'title' => $route->getPage()->title ?? null, ]; })->values()->all(); file_put_contents('routes.json', json_encode($export, JSON_PRETTY_PRINT)); echo "Exported " . count($export) . " routes to routes.json\n"; // Example output: // [ // { // "key": "index", // "path": "_site/index.html", // "type": "BladePage", // "title": "Home" // }, // { // "key": "posts/my-first-post", // "path": "_site/posts/my-first-post.html", // "type": "MarkdownPost", // "title": "My First Post" // } // ] ``` -------------------------------- ### Create Custom Blade Page for Contact Form Source: https://context7.com/hydephp/hyde/llms.txt This snippet demonstrates how to create a custom contact page using Laravel Blade templates within the `_pages/` directory. It includes a basic form submission using Formspree and utilizes Hyde's layout components. No external dependencies are required beyond HydePHP itself. ```blade {{-- _pages/contact.blade.php --}} @extends('hyde::layouts.app') @section('content') @php($title = 'Contact Us')

{{ $title }}

Get in touch with us through the following channels:

Send us a message

@endsection ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.