- How do I install Carve PHP in a Laravel app?
- Install it with Composer by requiring markup-carve/carve-php in your Laravel project. Run composer require markup-carve/carve-php from the application root, then instantiate the parser or renderer where needed. Basic HTML conversion does not require publishing assets, though you should check the README for optional configuration.
- Does Carve PHP work with Laravel without a service provider?
- Carve PHP is a standalone PHP package, so it does not require a Laravel service provider for basic use. You can instantiate its parser and renderer directly in controllers, jobs, or view composers. If you want dependency injection or shared configuration, bind it in a small custom service provider in your app.
- What is Carve and how is it different from Markdown?
- Carve is a lightweight, Markdown-inspired markup language designed for documents and the web. Carve PHP implements its parser and HTML renderer, offering extensible syntax and safe rendering rather than being a drop-in Markdown parser. If you need strict Markdown compatibility, verify the supported syntax in the package documentation.
- How do I convert Carve markup to HTML in PHP?
- Create a parser or renderer instance from the package, pass your Carve source string, and receive HTML output. The exact API is documented in the repository README, but typical usage is a single parse or render call. You can then return the HTML from a controller, store it, or pass it to a Blade view.
- Is Carve PHP safe for rendering user-submitted content?
- Carve PHP emphasizes safe rendering, but you should still treat user-submitted markup as untrusted. Review which HTML elements and attributes the renderer allows, and add a dedicated HTML sanitizer such as HTMLPurifier if your threat model requires stricter output. Also escape any non-markup user data that you interpolate outside the parser.
- Can I extend Carve PHP with custom syntax or renderers?
- Yes, the package is described as having extensible syntax, so you can add or customize parsing and rendering behavior. The repository README and source code are the best references for extension points such as custom node renderers or syntax rules. Keep custom extensions covered by tests because they can affect output safety.
- Which Laravel and PHP versions does Carve PHP support?
- Carve PHP is a Composer package, so its PHP and framework compatibility is defined in its composer.json constraints. It is not tied to a specific Laravel release for core parsing, meaning any Laravel version that satisfies the PHP requirement can use it. Check the package composer.json and release notes before upgrading Laravel or PHP.
- How do I test Carve rendering in Laravel feature tests?
- In Laravel feature tests, send a request that uses Carve and assert against the rendered HTML response. For unit tests, pass representative Carve strings to the parser and compare the output or assert that expected elements are present. Include tests for edge cases such as raw HTML, links, and custom extensions to protect against regressions.
- What are alternatives to Carve PHP for Markdown parsing in Laravel?
- Common alternatives for Markdown in Laravel include league/commonmark, erusev/parsedown, and michelf/php-markdown. Choose Carve PHP when you specifically want the Carve language and its extensible, safety-focused rendering. If you need strict CommonMark compatibility or a large Markdown extension ecosystem, league/commonmark is often the safer comparison.
- Is Carve PHP actively maintained and production-ready?
- Assess maintenance by checking the GitHub repository for recent commits, tagged releases, and open issues before adopting it. For production, pin a tested version in composer.json, review the safe-rendering behavior, and add tests around the markup your application accepts. Because it is a smaller, newer language implementation, confirm that its feature set and support cadence match your project risk tolerance.