Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skiarsi's avatar

composer run dev port number

Hi everyone. I want to run my app in another port number like 7000 with composer run dev. how can i do it

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

To run your application on a different port using composer run dev, you need to modify the script in your composer.json file to specify the desired port. Here's how you can do it:

  1. Open your composer.json file.
  2. Locate the scripts section.
  3. Modify the script that runs your development server to include the port option.

For example, if you are using a typical setup with Laravel Mix or a similar tool, your composer.json might look like this:

{
    "scripts": {
        "dev": "npm run dev"
    }
}

You would need to modify the npm run dev command to include the port. Assuming you are using a tool like Laravel Mix with Webpack, you can pass the port directly in the script. Here's an example:

{
    "scripts": {
        "dev": "npm run dev -- --port 7000"
    }
}

If you are using a different setup, such as a custom server script, you would adjust the command accordingly. For instance, if you are using a Node.js server, you might have something like:

{
    "scripts": {
        "dev": "node server.js --port 7000"
    }
}

After making these changes, you can run your development server on port 7000 by executing:

composer run dev

Make sure that your development server or tool supports passing the port as a command-line argument. If it doesn't, you may need to configure the port in the server's configuration file or environment variables.

1 like

Please or to participate in this conversation.