Giter Club home page Giter Club logo

Comments (6)

WanWizard avatar WanWizard commented on August 23, 2024 1

Which php binary do you use? Check the output of php -v. You should see

[wanwizard@alfred] $ php -v
PHP 8.2.5 (cli) (built: Apr 11 2023 16:16:23) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.5, Copyright (c), by Zend Technologies
    with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans

indicating the cli binary is used.

from core.

WanWizard avatar WanWizard commented on August 23, 2024 1

p.s. changing \Fuel::$is_cli doesn't magically enable CLI, it is a 'read-only' variable indicating whether or not you are runing in CLI mode.

You should not run tasks from a web request, which I suspect is what you are doing, they have not been designed to work that way.

If you insist, you can work around this issue by adding this to your code:

if(!defined('STDIN'))  define('STDIN',  fopen('php://stdin',  'rb'));
if(!defined('STDOUT')) define('STDOUT', fopen('php://stdout', 'wb'));
if(!defined('STDERR')) define('STDERR', fopen('php://stderr', 'wb'));

from core.

WanWizard avatar WanWizard commented on August 23, 2024

The STDOUT and STDERR constants are only defined in the cli version of php, the Cli class is not meant to be used bu the cgi version.

How are you using this exactly?

from core.

daisuke1101 avatar daisuke1101 commented on August 23, 2024

I am using FuelPHP 1.9/dev in
PHP 8.0.27, FPM/FastCGI mode.

The STDOUT and STDERR constants are only defined in the cli version of php, the Cli class is not meant to be used bu the cgi version.


I APOLOGIZE for the IGNORANCE.

from core.

daisuke1101 avatar daisuke1101 commented on August 23, 2024

In the function in MODEL or CONTROLLER,
When RUNNING TASKS,
I TOGGLED cli mode BETWEEN FALSE and TRUE.

        // Loading oil Package
        \Package::load('oil');

        // Environment Setting
        // Assign DEFAULT cli mode flag to $bf
        $bf = \Fuel::$is_cli;
        // TOGGLE cli mode TRUE
        \Fuel::$is_cli = true;
        // Define Count of Arguments
        $_SERVER['argc'] = 1;

        // Run Task
        // FORMAT: \Oil\Refine::run('[TASK File Name]:[Function]', array([Arguments]));
        \Oil\Refine::run('hoge:fuga', array($arg));
        // TOGGLE cli mode DEFAULT(= FALSE)
        \Fuel::$is_cli = $bf;

For your reference(JAPANESE SITE,CAUTION!),

https://qiita.com/goosys/items/d9dff999db4239f75dc1

from core.

daisuke1101 avatar daisuke1101 commented on August 23, 2024

Which php binary do you use? Check the output of php -v. You should see

[wanwizard@alfred] $ php -v
PHP 8.2.5 (cli) (built: Apr 11 2023 16:16:23) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.5, Copyright (c), by Zend Technologies
    with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans

indicating the cli binary is used.

My ENVIRONMENT IS

$ php -v
PHP 8.0.27 (cli) (built: Jan  3 2023 16:17:26) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.27, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.27, Copyright (c), by Zend Technologies

p.s. changing \Fuel::$is_cli doesn't magically enable CLI, it is a 'read-only' variable indicating whether or not you are runing in CLI mode.

You should not run tasks from a web request, which I suspect is what you are doing, they have not been designed to work that way.

THANK YOU FOR YOUR ADVICE.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.