Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP_CLI_SERVER_WORKERS has no effect even with --no-reload option #54723

Closed
alanfzf opened this issue Feb 20, 2025 · 2 comments · Fixed by #54724
Closed

PHP_CLI_SERVER_WORKERS has no effect even with --no-reload option #54723

alanfzf opened this issue Feb 20, 2025 · 2 comments · Fixed by #54724
Labels

Comments

@alanfzf
Copy link

alanfzf commented Feb 20, 2025

Laravel Version

11.43.2

PHP Version

8.4.3

Database Driver & Version

No response

Description

As the title says it seems like PHP_CLI_SERVER_WORKERS has no effect even when i start the server with the following command php artisan serve --no-reload --host=0.0.0.0

Steps To Reproduce

  1. Set PHP_CLI_SERVER_WORKERS=5 env var
  2. Start the development server with php artisan serve --no-reload --host=0.0.0.0
  3. For e.g make a call to own internal api like this:
public function index(Request $request){
    $appUrl = env('APP_URL');
    // or with token what ever...
    $con =  Http::withHeaders([
        'Accept' => 'application/json',
        'Referer' => $appUrl,
        'Cookie' => request()->header('Cookie'),
        'X-CSRF-TOKEN' => csrf_token(),
    ])->baseUrl("$appUrl/api");
    $response = $con->get('/users/', []);
 
    // curl hangs with 30 sec timeout, as the api request cannot be processed in parallel

    return view('users.index', ['data'=>$response->object()]);
}

Image

@crynobone
Copy link
Member

@alanfzf What's your OS?

@alanfzf
Copy link
Author

alanfzf commented Feb 20, 2025

@alanfzf What's your OS?

I was able to test it briefly on macos 15.3 and arch-linux on the work, right now im at home and i spinned up a WSL Debian 12 machine, same result for the 3 operating systems.

EDIT: also worth mentioning that we are using nix flakes and direnv to set up the dev environment

Nix flake and flake.lock
{
description = "A multi-architecture flake for development environments";

inputs = {
  nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  flake-utils.url = "github:numtide/flake-utils";
};

outputs =
  {
    self,
    nixpkgs,
    flake-utils,
    ...
  }@inputs:

  flake-utils.lib.eachSystem [ "x86_64-darwin" "aarch64-darwin" "x86_64-linux" "aarch64-linux" ] (
    system:
    let
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };

      mkScript =
        name: text:
        let
          script = pkgs.writeShellScriptBin name text;
        in
        script;

      scripts = [
        (mkScript "php-debug-adapter" ''
          #!/bin/bash
          node ${pkgs.vscode-extensions.xdebug.php-debug}/share/vscode/extensions/xdebug.php-debug/out/phpDebug.js
        '')

        (mkScript "all-format" ''
          #!/bin/bash
          prettier . --check --write && blade-formatter --write "resources/**/*.blade.php" && php-cs-fixer fix --show-progress=dots
        '')

        (mkScript "lara-start" ''
          #!/bin/bash
          trap "echo 'killing php service...'; kill 0" SIGINT
          php artisan serve --no-reload --host=0.0.0.0  &
          php artisan queue:listen --verbose &
          pnpm run dev &
          wait
        '')
      ];

      phpWithXdebug = (
        pkgs.php84.buildEnv {
          extensions = (
            { enabled, all }:
            enabled
            ++ (with all; [
              xdebug
            ])
          );
          extraConfig = ''
            xdebug.mode=debug
            xdebug.start_with_request=yes
            xdebug.client_host=127.0.0.1
            xdebug.client_port=9003
            xdebug.log_level = 0
          '';
        }
      );

      devPackages = with nixpkgs; [
        # base stuff
        phpWithXdebug
        pkgs.nodejs_22
        pkgs.pnpm
        pkgs.curl
        pkgs.zip
        pkgs.unzip
        pkgs.pdftk
        # php packages
        pkgs.php84Packages.composer
        pkgs.php84Packages.php-cs-fixer
        # extensions
        pkgs.php84Extensions.intl
        pkgs.php84Extensions.bcmath
        pkgs.php84Extensions.curl
        pkgs.php84Extensions.mysqli
        pkgs.php84Extensions.xml
        pkgs.php84Extensions.zip
        pkgs.php84Extensions.soap
        pkgs.php84Extensions.mbstring
        pkgs.php84Extensions.gd
        pkgs.php84Extensions.ftp
        pkgs.php84Extensions.xdebug
        # development
        pkgs.intelephense
        pkgs.typescript-language-server
        pkgs.blade-formatter
        pkgs.nodePackages.prettier
        pkgs.vscode-extensions.xdebug.php-debug
      ];

      postShellHook = '''';
    in
    {
      devShells = {
        default = pkgs.mkShell {
          name = "control-finanssoreal";
          nativeBuildInputs = scripts;
          packages = devPackages;
          postShellHook = postShellHook;
        };
      };
    }
  );
}
{
  "nodes": {
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1731533236,
        "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1739866667,
        "narHash": "sha256-EO1ygNKZlsAC9avfcwHkKGMsmipUk1Uc0TbrEZpkn64=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "73cf49b8ad837ade2de76f87eb53fc85ed5d4680",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nixpkgs": "nixpkgs"
      }
    },
    "systems": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

crynobone added a commit that referenced this issue Feb 20, 2025
taylorotwell pushed a commit that referenced this issue Feb 20, 2025
…nt` (#54724)

* [11.x] Fix parsing `PHP_CLI_SERVER_WORKERS` as `string` instead of `int`

fixes #54723

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Update src/Illuminate/Foundation/Console/ServeCommand.php

Co-authored-by: Julius Kiekbusch <[email protected]>

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: Julius Kiekbusch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants