[Suggestion] composer post-install-cmd that includes npm packages

Open
#1,466 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
php, playwright

Research direction

Start by reviewing the pest composer.package configuration and the pestphp/pest-plugin-browser installation flow. Compare the proposed Composer and Playwright commands with the linked laravel/sail PR, then determine the approved cross-platform behavior and how installation success should be verified.

Written by the indexing model from the issue text.

Description

I'm creating a issue instead of a PR, to open it for discussion before approval

When installing pestphp/pest-plugin-browser you need to run

composer require pestphp/pest-plugin-browser --dev
 
npm install playwright@latest
npx playwright install

You could create a post-install-cmd in pest composer.package
that would automatically run

npx -y npm-add-script -k postinstall -v "cross-env PLAYWRIGHT_BROWSERS_PATH=0 && npx playwright install"
npm install playwright cross-env
npm install

This will include in package.json

    "scripts": {
        ...
        "postinstall": "cross-env PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install-deps && npx playwright install"
    },
    "devDependencies": {
        ...
        "playwright": "^1.55.0",
    },

Note: cross-env PLAYWRIGHT_BROWSERS_PATH=0 allows to playwright browsers to be installed on node_modules folder, avoiding the need of user permissions or running as sudo

this way it will work on any Operational System (because cross-env handles the envrionment variable), also it will be executed every time you run composer require pestphp/pest-plugin-browser --dev


The only thing that will be needed is to run

npx playwright install-deps

This command make sure all required dependencies for playwright are already installed

I created a PR on laravel/sail package that already address it

Dominant language
PHP
Stars
11.7k
Forks
538
Avg merge
4d 11h
Merged PRs (30d)
8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pestphp/pest

All issues in pestphp/pest

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.