phpcodeigniter-4

PHP Spark Serve looking some port and exited


I just run php spark serve, and this happen

CodeIgniter v4.3.2 Command Line Tool - Server Time: 2023-03-14 05:43:21 UTC+00:00

CodeIgniter development server started on http://localhost:8080
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8081
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8082
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8083
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8084
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8085
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8086
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8087
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8088
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8089
Press Control-C to stop.
CodeIgniter development server started on http://localhost:8090
Press Control-C to stop.

I have changed the port with php spark serve --port 8000. The result is same. still looking some port.


Solution

  • Maybe you can read this thread: enter link description here

    I have kinda this problem too, running on osx 10.13 with php mamp 8.1.x

    First you need to check list port that php server running by this command on terminal:

    ps -ef | grep php
    

    then this will result

      501   714   637   0  3:21PM ??         1:35.58 php /Users/oreyon/.vscode/extensions/zobo.php-intellisense-1.1.3/vendor/felixfbecker/language-server/bin/php-language-server.php --tcp=127.0.0.1:49712 --memory-limit=4095M
      501  6428  6359   0  5:02PM ttys006    0:00.14 php spark serve
      501  6429  6428   0  5:02PM ttys006    0:00.05 /Applications/MAMP/bin/php/php8.1.13/bin/php -S localhost:8080 -t /Applications/MAMP/htdocs/siabsensmkn3/public/ /Applications/MAMP/htdocs/siabsensmkn3/vendor/codeigniter4/framework/system/Commands/Server/rewrite.php
      501  6471  6431   0  5:02PM ttys007    0:00.00 grep php
    

    The column number 2 is the PID port

    You can type on terminal

    kill 6428 
    

    this will remove process pid 6428 which is spark serve process

    check again list PID with

    ps -ef | grep php
    

    if there is no php spark on the list, then you have succeeded

      501   714   637   0  3:21PM ??         1:35.58 php /Users/oreyon/.vscode/extensions/zobo.php-intellisense-1.1.3/vendor/felixfbecker/language-server/bin/php-language-server.php --tcp=127.0.0.1:49712 --memory-limit=4095M
      501  6532  6477   0  5:09PM ttys007    0:00.00 grep php
    

    Don't forget to close terminal on php spark serve you running on, for me even if i kill the PID the list still will be there if we no close the terminal.

    you can try running the spark serve with command:

    php spark serve --port=8080
    

    so you use only one port.

    To prevent another port process the same serve, you can running spark serve on terminal.

    So when you press control + c the spark serve will stop, no notification though, but you can make sure this will work or no with ps -ef | grep php

    Hope this help