Configuration
Configure paths, routes, and search settings
Configuration
After installation, configure the package by publishing and editing the configuration file.
Publishing Configuration
Publish the configuration file to your config directory:
php artisan vendor:publish --tag=oi-documentation-configThis creates config/oi-documentation.php which you can customize.
Configuration Options
Here's the complete configuration file with all available options:
return [
/**
* The filesystem path where documentation files are stored.
* Relative to the resources directory.
*/
'docs_path' => 'markdown/docs',
/**
* The filesystem path where published React components are located.
* Relative to the resources/js directory.
*/
'components_path' => 'components/documentation',
/**
* The name of the generated navigation file.
* Auto-generated by doc:gen-nav command.
*/
'navigation_file' => 'navigation.json',
/**
* The name of the generated search index file.
* Auto-generated by doc:gen-index command.
*/
'search_index_file' => 'search-index.json',
/**
* Route configuration for the documentation pages.
*/
'route' => [
/**
* Enable or disable the documentation routes.
* Set to false if you want to define custom routes.
*/
'enabled' => true,
/**
* The URL prefix for all documentation routes.
* Documentation will be available at /{prefix}.
*/
'prefix' => 'documentation',
/**
* Middleware stack applied to documentation routes.
* Configured during installation based on access control preference.
*/
'middleware' => ['web'],
],
/**
* Search functionality configuration.
*/
'search' => [
/**
* Minimum query length to perform a search.
* Prevents performance issues with very short queries.
*/
'min_query_length' => 2,
/**
* Length of the excerpt shown in search results.
* Number of characters to display from matching content.
*/
'excerpt_length' => 150,
/**
* Context characters to include around matched terms in excerpts.
* Characters shown before and after the matched word.
*/
'excerpt_context' => 50,
],
];Configuration Explanation
docs_path
Specifies where your markdown documentation files are located. This is relative to the resources directory.
Default: markdown/docs
Example: If set to markdown/docs, your documentation structure would look like:
resources/markdown/docs/
├── getting-started/
│ ├── _index.md
│ └── installation.md
├── configuration/
│ └── _index.md
└── ...
components_path
The location of your published React components. This is relative to resources/js.
Default: components/documentation
Note: This should match where you published the components during installation.
navigation_file & search_index_file
Names of auto-generated JSON files created by the package commands.
Default: navigation.json and search-index.json
Important: Never edit these files manually. They're regenerated by doc:gen-nav and doc:gen-index commands.
route.enabled
Enable or disable automatic route registration.
Default: true
Use Cases:
- Set to
falseif you want to define custom documentation routes - Keep as
truefor automatic route management
route.prefix
The URL prefix for your documentation site.
Default: documentation
Examples:
- Prefix
documentation→ Documentation available at/documentation - Prefix
docs→ Documentation available at/docs - Prefix
help→ Documentation available at/help
route.middleware
Middleware stack applied to all documentation routes.
Default: ['web'] (varies based on installation choice)
Examples:
- Public:
['web'] - Authenticated:
['web', 'auth'] - Admin only:
['web', 'auth', 'admin']
See Access Control for more details.
search.min_query_length
Minimum number of characters required before searching.
Default: 2
Rationale: Prevents performance issues with single-character searches while still supporting searches like "php".
search.excerpt_length
Number of characters to display in search result excerpts.
Default: 150
Consideration: Longer excerpts provide more context but take more space in results.
search.excerpt_context
Number of characters before and after the matched term in excerpts.
Default: 50
Example: With excerpt_context: 50, a match of "search" might show 50 characters before and 50 after the word.
Changing Configuration
You can safely modify configuration values after installation. Common changes:
// Change documentation URL
'route' => [
'prefix' => 'help', // Now available at /help
],
// Tighten search requirements
'search' => [
'min_query_length' => 3, // Require 3+ characters
],
// Change documentation path
'docs_path' => 'docs', // Use resources/docs insteadAfter changing configuration, regenerate navigation and search index:
php artisan doc:gen-nav
php artisan doc:gen-indexEnvironment Configuration
For environment-specific configuration, use environment variables:
'route' => [
'prefix' => env('DOCUMENTATION_PREFIX', 'documentation'),
'enabled' => env('DOCUMENTATION_ENABLED', true),
],Then in your .env:
DOCUMENTATION_PREFIX=docs
DOCUMENTATION_ENABLED=true