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:
- Open your
composer.jsonfile. - Locate the
scriptssection. - 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.