This document discusses using PHP as a shell scripting language by leveraging its familiarity, flexibility, and ease of use for tasks like data processing, long running processes, tools/utilities, and component testing. It covers how to set up PHP scripts with a shebang line to be executable from the command line. It provides examples of using system calls, reading from and writing to standard streams, and parsing command line arguments. The key points are that PHP can be a useful alternative to traditional shell scripts while also taking advantage of its programming language features.
This document discusses using PHP as a shell scripting language by leveraging its familiarity, flexibility, and ease of use for tasks like data processing, long running processes, tools/utilities, and component testing. It covers how to set up PHP scripts with a shebang line to be executable from the command line. It provides examples of using system calls, reading from and writing to standard streams, and parsing command line arguments. The key points are that PHP can be a useful alternative to traditional shell scripts while also taking advantage of its programming language features.
LINE LIVE is a video streaming and hosting service that allows users to watch streams from celebrities and companies or host their own streams. It uses HTTP Live Streaming (HLS) to deliver video content through media servers to viewers via a CDN. Streams can be viewed on LINE and chat functionality allows users to communicate and show appreciation through "Loves". The service has grown significantly since its launch in 2014 and now handles over 10,000 chat messages and millions of "Loves" per stream through scaled infrastructure including servers, storage systems and a Redis cluster to support low-latency interactions.
The document provides an introduction to PHP programming. It discusses PHP basics like syntax and variables, learning resources like tutorials and documentation references, and advanced PHP topics for more experienced developers like functions, arrays, and object-oriented programming. The goal is to help new PHP programmers learn the language and give them guidance on where to go to continue developing their skills.
42. Perlだと?(雰囲気です)
package Index;
use Mouse;
extends 'Base';
has slim => ( is => 'rw', isa => 'Slim' );
sub run {
my ($self) = @_;
$self->slim->render('template/index.tt');
}
no Mouse;
1;
70. • https://github.com/reactphp/react
「Event-driven, non-blocking I/O with PHP.」
• https://github.com/ratchetphp/Ratchet
WebSocketサーバー(スタンドアロンでサーバ
ーになります)
• https://github.com/marcj/php-pm
「PHP ProcessManager for Request-Response
Applications」
71. • https://github.com/videlalvaro/phacterl
「Implementation of The Actor Model in
PHP.」
「アクターモデル」「マジで!?」
• https://github.com/ircmaxell/PHPPHP
「A PHP VM implementation written in PHP.」
「PHPでPHP実装した」「マジで?!」
• https://github.com/runekaagaard/snowscript
要はPHPのCoffeScript、更新ほぼない
88. Perl (Plack)
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use JSON::XS qw(encode_json);
my $app = sub {
my $env = shift;
return [
200,
[ 'Content-Type' => 'application/json' ],
[ encode_json({ message => 'Hello, World!' }) ],
];
};
return $app;
変哲のない生PlackなHelloWorldウェブアプリ
89. 突然ですがベンチマーク
• 環境
• Vultr (VPS) の下から二つ目のプラン
• 1コア (Vultr Virtual CPU 3392Mhz)
• Mem 1024MB、SSD
• CentOS6
90. Perl 5.20.0
start_server --port=5000 --backlog 16384
-- plackup -E production -s Starlet --max-keepalive-
reqs 1000 --max-reqs-per-child
50000 --min-reqs-per-child 40000 --max-worker
1 -a ./helloworld.psgi
ab -n 10000 -c 10
91. result - perl
Server Software: Plack::Handler::Starlet
Server Hostname: 127.0.0.1
Server Port: 5000
Document Path: /
Document Length: 27 bytes
Concurrency Level: 10
Time taken for tests: 1.606 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1670000 bytes
HTML transferred: 270000 bytes
Requests per second: 6225.76 [#/sec] (mean)
Time per request: 1.606 [ms] (mean)
Time per request: 0.161 [ms] (mean, across all concurrent requests)
Transfer rate: 1015.33 [Kbytes/sec] received
92. result - perl
Concurrency Level: 10
Complete requests: 10000
Requests per second: 6225.76 [#/sec] (mean)
97. result - php + reactPHP
Server Software:
Server Hostname: 127.0.0.1
Server Port: 5000
Document Path: /
Document Length: 36 bytes
Concurrency Level: 10
Time taken for tests: 3.397 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1420000 bytes
HTML transferred: 360000 bytes
Requests per second: 2943.53 [#/sec] (mean)
Time per request: 3.397 [ms] (mean)
Time per request: 0.340 [ms] (mean, across all concurrent requests)
Transfer rate: 408.18 [Kbytes/sec] received
98. result - php + reactPHP
Concurrency Level: 10
Complete requests: 10000
Requests per second: 2943.53 [#/sec] (mean)
102. result - HHVM
Server Software:
Server Hostname: 127.0.0.1
Server Port: 5000
Document Path: /index.php
Document Length: 36 bytes
Concurrency Level: 10
Time taken for tests: 1.230 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1420000 bytes
HTML transferred: 360000 bytes
Requests per second: 8132.90 [#/sec] (mean)
Time per request: 1.230 [ms] (mean)
Time per request: 0.123 [ms] (mean, across all concurrent requests)
Transfer rate: 1127.81 [Kbytes/sec] received
103. result - HHVM
Concurrency Level: 10
Complete requests: 10000
Requests per second: 8132.90 [#/sec] (mean)
109. HHVM httpd result
Server Software:
Server Hostname: 127.0.0.1
Server Port: 5000
Document Path: /index.php
Document Length: 27 bytes
Concurrency Level: 10
Time taken for tests: 1.704 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1240000 bytes
HTML transferred: 270000 bytes
Requests per second: 5868.96 [#/sec] (mean)
Time per request: 1.704 [ms] (mean)
Time per request: 0.170 [ms] (mean, across all concurrent requests)
Transfer rate: 710.69 [Kbytes/sec] received
110. HHVM httpd result
Concurrency Level: 10
Complete requests: 10000
Requests per second: 5868.96 #/sec
118. php the right way
http://ja.phptherightway.com/
安心の日本語翻訳です。ここをよめばとりあえず
最初迷わないでしょう。
PerlMongerの人はこれだけ覚えて帰って下さい。
(ちなみに、PHPの情報を集めるなら、
できれば海外の物が良いでしょう…
まあ、海外もスットコな情報多いですが)
119. 基本的に以上ですが…時間は
あまっている?
One more thing「s」
または
質問タイム
ーーーーーーーーーーー
YAPC登壇者3人+パーフェク
トRuby執筆者1人が書いた
「Webアプリケーション
エンジニア養成読本」
好評発売中!
174. 余談:namespaceがが区切り文字
ということは…
<?php
namespace ¥¥{
class ¥{
static public function ¥(){
echo " is not ¥".PHP_EOL;
}
}
}
namespace {
¥¥¥::¥();
}
こういうコードが可能なので…