LaRecipe Documentation

repository·main·Indexed 25 days ago

https://github.com/saleem-hadad/larecipe

A code-driven Laravel package for creating integrated product documentation directly within a Laravel application. It includes tools for scaffolding assets and themes via Artisan commands (larecipe:asset, larecipe:theme), managing documentation versions through DocumentationRepository, and configuring search, authentication, and custom styles/scripts.

Tokens
2.6K
Snippets
2
Records
23
Agent score
79%

What's inside LaRecipe

  1. Explore official LaRecipe tools and assets

    main

    LaRecipe supports several official extensions to enhance your documentation experience:

    • LaRecipe Dark Theme: For dark mode support.
    • LaRecipe RTL Support: For Right-to-Left language support.
    • LaRecipe Feedback: To allow users to provide feedback on documentation.
    • LaRecipe Swagger: For integrating Swagger/OpenAPI documentation.
  2. Install and set up LaRecipe

    main

    To integrate LaRecipe into your Laravel application, follow these two steps:

    1. Install the package via Composer:
      composer require binarytorch/larecipe
    2. Run the Artisan installation command to publish assets and configuration:
      php artisan larecipe:install

    Once installed, you can access your documentation by visiting the /docs endpoint on your application's domain.

    composer require binarytorch/larecipe
    php artisan larecipe:install
  3. Configure search visibility and access rules

    main

    The search endpoint (invoked via __invoke($version)) enforces access control based on the following configuration logic:

    1. Enabled Status: Search must be enabled via config('larecipe.search.enabled').
    2. Version Status: The requested $version must be a published version according to the DocumentationRepository.
    3. Access Mode: If config('larecipe.search.default') is not set to 'internal', access is restricted.

    If any of these conditions fail, the controller returns a 403 Forbidden response.

  4. Publish LaRecipe configuration, assets, and views

    main

    To customize the package, you can publish its configuration, assets, and partial views using the Laravel vendor:publish command. The following tags are available:

    • larecipe_config: Publishes the configuration file to config/larecipe.php.
    • larecipe_assets: Publishes assets to public/vendor/binarytorch/larecipe/assets.
    • larecipe_views: Publishes partial views to resources/views/vendor/larecipe/partials.
  5. Configure LaRecipe routes and middleware

    main

    LaRecipe's routing behavior is controlled via the larecipe configuration file. You can customize the following settings:

    • larecipe.docs.route: The URL prefix for the documentation routes.
    • larecipe.domain: A custom domain for the documentation (set to null to use the application's default domain).
    • larecipe.docs.middleware: Middleware applied to the documentation routes.

    The routes are assigned the name prefix larecipe..

  6. Configure documentation versions and landing pages

    main

    The DocumentationRepository relies on the following configuration keys to determine routing and visibility:

    • larecipe.versions.default: The default version used for canonical URLs and fallback logic.
    • larecipe.versions.published: An array of versions that are considered 'published'.
    • larecipe.docs.landing: The default page/section to show when no specific page is requested in the get() method.
  7. Configure authentication and middleware for documentation

    main

    The documentation access is controlled via the larecipe.settings configuration keys. You can specify which authentication guard to use, whether to require authentication, or to apply custom middleware to the documentation routes.

    • larecipe.settings.guard: If set, the controller will use this specific Laravel authentication guard.
    • larecipe.settings.auth: If true, the auth middleware is applied to all documentation routes.
    • larecipe.settings.middleware: If auth is not enabled, you can specify a custom array of middleware to apply via this key.
  8. Configure LaRecipe caching behavior

    main

    LaRecipe uses a caching mechanism to store documentation data. You can control whether caching is active and how long items are stored using the larecipe.cache configuration keys.

    Note that the cache duration is handled differently depending on your Laravel version:

    • For Laravel 5.8+ or Laravel 6+, the larecipe.cache.period value is treated as minutes and is automatically converted to seconds internally.
    • For older versions, the value is treated as seconds.
  9. Configure search access and middleware

    main

    The SearchController behavior is controlled by several configuration keys in larecipe.php.

    • Authentication: If larecipe.settings.auth is set to true, the search endpoint is protected by the auth middleware.
    • Custom Middleware: If authentication is disabled, you can specify custom middleware using larecipe.settings.middleware.
    • Search Availability: The search functionality is governed by larecipe.search.enabled and larecipe.search.default.
  10. Configure default documentation version and landing page

    main

    The documentation routing relies on the following configuration keys to determine where users are redirected when accessing the index or unreleased versions:

    • larecipe.versions.default: The version string used for the default documentation version.
    • larecipe.docs.landing: The page slug used for the documentation landing page.

    These keys are used by the index() method to redirect users to the correct starting point.