Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phantomjs Installer Laravel Package

jakoch/phantomjs-installer

Composer package that downloads and installs the PhantomJS binary for Linux, macOS, and Windows into your project’s bin directory. Supports version pinning, platform overrides, custom mirrors, and retrying downloads with version fallback.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Use Case Alignment: Remains ideal for Laravel/PHP projects requiring headless browser automation (e.g., PDF generation, screenshots) via PhantomJS, but deprecation risk is critical. The package’s core value (avoiding manual PhantomJS installation) persists, though long-term viability is questionable.
  • Isolation: Project-specific /bin directory installation unchanged, mitigating system-wide conflicts. New Risk: Exception-throwing behavior (3.0.3) may break silent failures, forcing explicit error handling.
  • Extensibility: Still pairs with Laravel libraries like spatie/pdf-to-text, but PhantomJS’s EOL status (2018) and lack of maintainer updates (e.g., no patches for CVEs) make this a high-risk dependency. Alternatives (Puppeteer/Playwright) are strongly recommended.

Integration Feasibility

  • Composer Integration: Unchanged—zero-configuration via composer require jakoch/phantomjs-installer. However, 3.0.3’s exception-throwing requires updates to error-handling logic (e.g., try-catch blocks around installation).
  • Laravel Compatibility: Works with Artisan commands/service providers, but new exception behavior may expose installation failures earlier in the pipeline (e.g., during composer install).
  • Binary Path Handling: Path resolution remains manual (e.g., base_path('/bin/phantomjs')), but 3.0.3’s stricter validation may surface path issues in CI/CD pipelines.

Technical Risk

  • Deprecation Risk (Elevated): PhantomJS is abandoned upstream, and the package maintainer has not addressed critical vulnerabilities (e.g., CVE-2023-4617). 3.0.3’s exception-throwing is a stopgap, not a solution.
    • Mitigation:
      • Immediate: Add a try-catch around installation in composer.json:
        "scripts": {
            "post-install-cmd": [
                "@php -r \"try { require __DIR__.'/vendor/autoload.php'; $installer = new \\Jakoch\\PhantomJs\\Installer; $installer->install(); } catch (\\Exception $e) { echo 'PhantomJS install failed: '.$e->getMessage().'\\n'; exit(1); }\""
            ]
        }
        
      • Long-term: Migrate to Puppeteer/Playwright (via puppeteer/puppeteer or playwright/php) with a parallel feature-compatibility matrix.
  • Binary Compatibility: PhantomJS versions may still break with newer Node.js/Laravel dependencies. 3.0.3’s changes could expose OS-specific issues (e.g., Windows path handling).
  • Resource Overhead: Unchanged—PhantomJS remains memory-intensive (~500MB+ per instance). New Risk: Exception-throwing may cause CI/CD pipeline failures if downloads are blocked (e.g., corporate proxies).

Key Questions

  1. Why PhantomJS?
    • Is this for legacy code or a specific unsupported feature (e.g., old PDF rendering)?
    • Have modern alternatives (Puppeteer/Playwright) been evaluated for feature parity (e.g., PDF generation, screenshots)?
  2. Error Handling
    • How will 3.0.3’s exceptions be handled in CI/CD (e.g., GitHub Actions)?
    • Should the package be pinned to 3.0.2 to avoid breaking changes?
  3. Security
    • Are there plans to audit PhantomJS dependencies for CVEs, or will the package be abandoned?
    • Will Laravel’s security team flag this as a high-risk dependency?
  4. Migration Strategy
    • What’s the timeline for replacing PhantomJS (e.g., 6-month deprecation window)?
    • Are there Laravel-specific wrappers for Puppeteer/Playwright (e.g., spatie/laravel-playwright)?

Integration Approach

Stack Fit

  • PHP/Laravel: Native Composer integration remains seamless, but 3.0.3’s exception-throwing requires updates to:
    • Artisan Commands: Wrap exec() calls in try-catch blocks.
    • Service Providers: Verify PhantomJS path exists before use:
      if (!file_exists($phantomJsPath)) {
          throw new \RuntimeException('PhantomJS not installed. Run `composer install`.');
      }
      
  • Frontend/Backend: Still useful for backend APIs, but deprecation timeline must be communicated to stakeholders.

Migration Path

  1. Phase 0 (Immediate): Update error handling for 3.0.3:
    composer require jakoch/phantomjs-installer:^3.0
    
    "scripts": {
        "post-install-cmd": [
            "@php -r \"try { require __DIR__.'/vendor/autoload.php'; $installer = new \\Jakoch\\PhantomJs\\Installer; $installer->install(); } catch (\\Exception $e) { echo 'PhantomJS install failed: '.$e->getMessage().'\\n'; exit(1); }\""
        ]
    }
    
  2. Phase 1: Integrate into a single use case (e.g., PDF generation) with fallback logging.
  3. Phase 2: Refactor into a wrapper class with deprecation warnings:
    class PhantomJsService {
        public function __construct(private string $path) {
            if (!file_exists($path)) {
                throw new \RuntimeException('PhantomJS deprecated; use Puppeteer instead.');
            }
        }
        // ...
    }
    
  4. Phase 3: Parallel development with Puppeteer/Playwright:
    • Example: Replace exec('phantomjs script.js') with:
      use Puppeteer\Puppeteer;
      $browser = await Puppeteer::launch();
      $page = await $browser->newPage();
      await $page->pdf(['path' => 'output.pdf']);
      
  5. Phase 4: Deprecate PhantomJS in favor of the new stack (e.g., via Laravel’s deprecated() helper).

Compatibility

  • OS: Unchanged (Linux/macOS/Windows), but 3.0.3 may expose path issues (e.g., Windows C:\ vs. /bin).
  • PHP Versions: Still PHP 8.0+, but exception-throwing may break older error-handling patterns.
  • Laravel Versions: No direct impact, but deprecation warnings should be added to AppServiceProvider.
  • Alternatives:
    • Puppeteer: puppeteer/puppeteer (Node.js) + php-bridge (e.g., spatie/php-bridge).
    • Playwright: playwright/php (native PHP port).
    • Headless Chrome: laravel-headless-chrome (wrapper for Puppeteer).

Sequencing

  1. Week 1: Update error handling for 3.0.3 and test in CI.
  2. Week 2: Add deprecation warnings to PhantomJS usage.
  3. Week 3-4: Develop Puppeteer/Playwright integration in parallel.
  4. Week 5-6: Feature parity testing (e.g., PDF generation, screenshots).
  5. Week 7+: Deprecate PhantomJS in production.

Operational Impact

Maintenance

  • Dependency Updates: Pin to 3.0.3 to avoid breaking changes. Monitor for security patches (unlikely).
  • PhantomJS Patches: No official support—expect to fork or migrate.
  • Documentation:
    • Update README with:
      • 3.0.3’s exception behavior.
      • Migration steps to Puppeteer/Playwright.
      • Known issues (e.g., Windows path handling).
    • Add a DEPRECATION.md with timeline and alternatives.

Support

  • Debugging:
    • New Issue: PhantomJS installer failed: Download not found → Check proxy/CI environment.
    • Workaround: Use a custom installer script or pre-downloaded binaries.
  • Common Issues:
    • CI Failures: Add a post-install-cmd with error handling (as above).
    • Production Crashes: Log PhantomJS errors to Sentry/Laravel logs.
  • Support Matrix:
    Issue Owner SLA
    3.0.3 installation failures DevOps 1h
    PhantomJS crashes TPM 24h
    Migration to Puppeteer Backend Team
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk