Yii Framework context in PHP Pthread Class

I am working on PHP Pthreads . I wrote a class that inherits the Thread class. This class does not recognize the context of the Yii structure (1.x). I cannot use any of the components or models of the Yii infrastructure. I made sure that the stream class must be in the accessible Yii structures defined in the import parameter.

Here is an example of how I wrote a stream class.

  <?php

    class MultiThreaded extends Thread {


            public function __construct(){

            }

            public function run(){
                       echo Yii::app()->basePath;
            }


    }

Update:

Here is the array of importers in the Yii configuration.

'import'=>array(
        'application.models.*',
        'application.components.*',
        'application.components.multithreaded-operations.*',
        'application.components.google_api_Lib.src.*',
        'application.controllers.*',
        'application.extensions.yii-mail.*',
        'application.extensions.*',
        'application.commands.*',

    ),  

Am I doing something wrong?

thanks

Harpine

+4
source share
1 answer

You need to install pthreads on your system.

For Wampp (Windows)

  • , PHP Extension Build, phpinfo(). - http://localhost/?phpinfo=1

  • pthreads, php (32- 64- ) php- ( VC11). - http://windows.php.net/downloads/pecl/releases/pthreads/

  • zip - php_pthreads.dll bin\php\ext \.

    pthreadVC2.dll "bin\php \".

    pthreadVC2.dll "bin\apache\bin".

    pthreadVC2.dll 'C:\windows\system32'.

  • php\php.ini = php_pthreads.dll

, .

LINUX SYSTEM:

1) PHP- PHP

2) PEAR    wget http://pear.php.net/go-pear.phar   php go-pear.phar

3) pthreads PECL (PECL - PHP)

pecl install pthread-0.4.4

4) pthreads pthread-0.4.4 php/ext (./configure --enable-pthreads)

mv build/php-src-master/ext/pthreads-master build/php-src-master/ext/pthreads

5)

./buildconf --force

./configure --help | grep pthreads

--enable-pthreads, ,

rm -rf aclocal.m4

rm -rf autom4te.cache/

./buildconf --force

6) PHP PHP :

./configure --enable-debug --enable-maintainer-zts --enable-pthreads

7) PHP

sudo make install

8) php.ini php.ini = pthreads.so Include_path = "/usr/local/lib/php"

9) php -m ( pthread)

10)

php SimpleTest.php

.

, :)

0

Source: https://habr.com/ru/post/1606909/


All Articles