当前位置: 首页 > 工具软件 > Recki-CT > 使用案例 >

快速提示:将Recki-CT安装到无所事事的Ubuntu盒子中

周弘毅
2023-12-01

Recki what?

雷基什么?

If you don’t know what Recki-CT is, see @ircmaxell’s original post or the repo, we won’t go into depth here. This quick tip will merely show you how to install it on a Homestead Improved box, much like we did with other software before.

如果您不知道什么是Recki-CT,请参阅@ircmaxell的原始帖子repo ,我们在这里不做进一步介绍。 这个快速提示将仅向您展示如何将其安装在Homestead Enhanced盒子上,就像我们之前使用其他软件所做的一样

步骤1 –改良宅基地 (Step 1 – Homestead Improved)

First and foremost, get a Homestead Improved instance up and running.

首先,要启动并运行Homestead Improvementd实例。

Give it a new virtual host like so:

为它提供一个新的虚拟主机,如下所示:

- map: test.app
  to: /home/vagrant/Code/recki

Boot the VM and vagrant ssh into it.

启动VM,然后将vagrant ssh导入其中。

第2步– JitFu (Step 2 – JitFu)

Recki-CT needs JitFu to be installed.

Recki-CT需要安装JitFu

As per instructions, run the following commands in order while you’re in the VM.

按照说明,在虚拟机中时,请依次运行以下命令。

sudo apt-get install bison flex texinfo

git clone git://git.sv.gnu.org/libjit.git libijt-fu
cd libjit-fu
./auto_gen.sh
./configure --prefix=/opt
make
sudo make install

git clone https://github.com/krakjoe/jitfu
cd jitfu
phpize
./configure --with-jitfu=/opt
make
sudo make install

sudo su
echo "extension=jitfu.so" >> /etc/php5/fpm/conf.d/20-jitfu.ini
echo "extension=jitfu.so" >> /etc/php5/cli/conf.d/20-jitfu.ini
exit

sudo service nginx restart
sudo service php5-fpm restart

To see if we installed it successfully:

要查看我们是否成功安装了它:

cd ~/Code
git clone https://github.com/Swader/publicinfo recki
mv recki/public/index.php recki/
touch recki/recki.php

Open recki.php and paste the following content inside it:

打开recki.php并将以下内容粘贴到其中:

<?php
use JITFU\Context;
use JITFU\Type;
use JITFU\Signature;
use JITFU\Func;
use JITFU\Value;

$context = new Context();

$integer   = Type::of(Type::int);

$function = new Func($context, new Signature($integer, [$integer]), function($args) use($integer) {
    $zero     = new Value($this, 0, $integer);
    $one      = new Value($this, 1, $integer);
    $two      = new Value($this, 2, $integer);

    /* if ($arg == 0) return 0; */
    $this->doIf(
        $this->doEq($args[0], $zero),
        function() use ($zero) {
            $this->doReturn($zero);
        }
    );

    /* if ($arg == 1) return 1; */
    $this->doIf(
        $this->doEq($args[0], $one),
        function() use($one) {
            $this->doReturn($one);
        }
    );

    /* return $function($arg-1) + $function($arg-2); */
    $this->doReturn(
        $this->doAdd(
            $this->doCall($this, [$this->doSub($args[0], $one)]),
            $this->doCall($this, [$this->doSub($args[0], $two)]))); 
});

$function->dump("Fibonacci");

var_dump($function(40)); /* __invoke with magicalness */
?>

If you go to test.app:8000 now, you should see JitFu support enabled in the PHPInfo screen. If you go to test.app:8000/recki.php, you should get int 102334155 as output rather quickly.

如果现在转到test.app:8000 ,则应该在PHPInfo屏幕中看到启用了JitFu支持。 如果转到test.app:8000/recki.php ,则应该很快获得int 102334155作为输出。

步骤3 –克隆和撰写 (Step 3 – Clone and Compose)

Next up, we’ll need to clone the Recki repo, and download dependencies with Composer.

接下来,我们需要克隆Recki存储库,并使用Composer下载依赖项。

cd ~/Code
rm -rf recki
git clone https://github.com/google/recki-ct recki
cd recki
composer install

步骤4 –测试 (Step 4 – Test)

To see if it works, just run the examples via the command line:

要查看它是否有效,只需通过命令行运行示例:

php examples/01-basic-usage.php

or through the browser:

或通过浏览器:

test.app:8000/examples/01-basic-usage.php


That’s all there is to it. Now you can focus on brutal optimizations of your PHP code in certain parts without having to replace the entire PHP engine your app is spinning on.

这里的所有都是它的。 现在,您可以集中精力对某些部分中PHP代码进行残酷的优化,而不必替换您的应用程序所依赖的整个PHP引擎。

翻译自: https://www.sitepoint.com/quick-tip-install-recki-ct-vagrant-ubuntu-box/

 类似资料: