php_embed 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +52 -11
- data/ext/php_embed/extconf.rb +18 -12
- data/lib/php_embed/version.rb +1 -1
- metadata +12 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 782cfc1f4de6d653d347cc3cc70e0c9d37bf2b33
|
4
|
+
data.tar.gz: ee0261b10f308d77515e0f01f9c304c0b736e668
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e432c902d19694ad620fe95e77ffc52a236e02525f47fa59bed032f17572ba0297189c6b485bc547997ec5b148db40acf5208f1a2c93bf9b53bb56959073bce
|
7
|
+
data.tar.gz: 26a55c63584c2153cdd2f44767f47d4c8d39e4d40ba122de9956a9f1fdad74a3fe0b3c69e7c1469da853f9cb0c82982fd32cf4b58eed0479ebd17b5f04cc509e
|
data/README.md
CHANGED
@@ -3,27 +3,67 @@ php_embed
|
|
3
3
|
|
4
4
|
Ruby 上で PHP のコードを実行します
|
5
5
|
|
6
|
+
Synopsis
|
7
|
+
-----------
|
8
|
+
```ruby
|
9
|
+
require 'php_embed'
|
10
|
+
|
11
|
+
puts PhpEmbed.call("phpversion") # output return value of phpversion function
|
12
|
+
|
13
|
+
|
14
|
+
PhpEmbed.eval('function hello_php(){ return "php world!";}')
|
15
|
+
puts PhpEmbed.call("hello_php") # "php world!"
|
16
|
+
|
17
|
+
|
18
|
+
PhpEmbed.setOutputHandler(Proc.new { |output|
|
19
|
+
puts output
|
20
|
+
})
|
21
|
+
PhpEmbed.call("phpinfo") # output phpinfo()
|
22
|
+
|
23
|
+
```
|
24
|
+
|
6
25
|
Requirements
|
7
26
|
-----------
|
8
27
|
* ruby >= 1.9
|
9
|
-
* php embed-sapi
|
10
|
-
|
11
|
-
ruby 1.9 系でしか動きません。
|
28
|
+
* php embed-sapi (optional)
|
12
29
|
|
13
|
-
コンパイル時に phpize が、
|
14
|
-
実行に php embed-sapi 共有ライブラリが、
|
15
|
-
それぞれ必要となります。
|
16
30
|
|
31
|
+
About php embed SAPI
|
32
|
+
----------
|
17
33
|
php をソースからコンパイルする場合、そのままでは embed-sapi はコンパイルされません。
|
18
|
-
configure 時に、 --enable-embed
|
34
|
+
configure 時に、 --enable-embed オプションを指定する必要があります。
|
19
35
|
|
20
|
-
CentOS6 であれば php-
|
36
|
+
CentOS6 であれば `php-embedded` と `php-devel` パッケージでも代替可能です。
|
21
37
|
|
22
38
|
|
23
39
|
Installation
|
24
40
|
-----------
|
25
|
-
|
26
|
-
|
41
|
+
|
42
|
+
###normal install
|
43
|
+
```
|
44
|
+
gem install php_embed
|
45
|
+
```
|
46
|
+
システムの php embed-sapi 共有ライブラリを利用します
|
47
|
+
利用出来ない場合、インストールは失敗します
|
48
|
+
|
49
|
+
|
50
|
+
###install with php compile
|
51
|
+
```
|
52
|
+
gem install -- --compile-php
|
53
|
+
```
|
54
|
+
|
55
|
+
インストール時に、php のソースコードを取得してコンパイルします
|
56
|
+
インストールされる php のバージョンは 5.6.0 です。
|
57
|
+
|
58
|
+
`--compile-php=5.5.17` のように、php のバージョンを指定することも可能です
|
59
|
+
|
60
|
+
|
61
|
+
##install with php compile (use old version)
|
62
|
+
```
|
63
|
+
gem install -- --compile-php=5.3.3 --php-source-url=http://museum.php.net/php5/php-5.3.3.tar.bz2
|
64
|
+
```
|
65
|
+
古いバージョンの php を使いたい場合、ソースコードがダウンロードできずにインストールに失敗する場合があります
|
66
|
+
その時は `--php-source-url` でダウンロードURLを指定できます
|
27
67
|
|
28
68
|
Usage
|
29
69
|
-----------
|
@@ -33,5 +73,6 @@ spec ディレクトリにある rspec を参考にしてください。
|
|
33
73
|
### Slide
|
34
74
|
http://www.slideshare.net/do_aki/php-in-ruby
|
35
75
|
|
36
|
-
php-embed となっているところは php_embed の誤りです。
|
76
|
+
Slide 中の php-embed となっているところは php_embed の誤りです。
|
77
|
+
|
37
78
|
|
data/ext/php_embed/extconf.rb
CHANGED
@@ -3,14 +3,15 @@ require 'fileutils'
|
|
3
3
|
require 'pathname'
|
4
4
|
require 'open-uri'
|
5
5
|
|
6
|
+
DEFAULT_PHP_VERSION = "5.6.0"
|
6
7
|
|
8
|
+
def default_download_url(php_version)
|
9
|
+
"http://php.net/distributions/php-#{php_version}.tar.bz2"
|
10
|
+
end
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def download_src(destfile)
|
12
|
-
print "download php source\n"
|
13
|
-
FileUtils.copy_stream(open(PHP_SRC_URL), destfile)
|
12
|
+
def download_source(url, destfile)
|
13
|
+
print "download php source from: #{url}\n"
|
14
|
+
FileUtils.copy_stream(open(url), destfile)
|
14
15
|
end
|
15
16
|
|
16
17
|
def decompression(archive)
|
@@ -64,15 +65,15 @@ def prepare_compile_php(prefix)
|
|
64
65
|
abort 'need make' unless find_executable 'make'
|
65
66
|
end
|
66
67
|
|
67
|
-
def compile_php(prefix)
|
68
|
+
def compile_php(version, url, prefix)
|
68
69
|
Dir.mkdir 'src' unless Dir.exists? 'src'
|
69
70
|
Dir.chdir('src') do
|
70
|
-
|
71
|
-
|
72
|
-
decompression(
|
71
|
+
filename = "php.tar.bz2"
|
72
|
+
download_source(url, filename) unless File.exists? filename
|
73
|
+
decompression(filename)
|
73
74
|
end
|
74
75
|
|
75
|
-
src_dir = "src/php-#{
|
76
|
+
src_dir = "src/php-#{version}"
|
76
77
|
if !Dir.exists? src_dir
|
77
78
|
abort 'soruce directory not exists'
|
78
79
|
end
|
@@ -97,11 +98,16 @@ have_libphp = have_library('php5', 'php_embed_init')
|
|
97
98
|
if !php_config || !have_libphp
|
98
99
|
php_version = arg_config('--compile-php')
|
99
100
|
abort 'libphp5 or php-config not found: try --compile-php' unless php_version
|
101
|
+
if php_version == true then
|
102
|
+
php_version = DEFAULT_PHP_VERSION
|
103
|
+
end
|
104
|
+
|
105
|
+
php_download_url = arg_config('--php-source-url', default_download_url(php_version))
|
100
106
|
|
101
107
|
prefix = Pathname.getwd.join('php')
|
102
108
|
|
103
109
|
prepare_compile_php(prefix.to_s)
|
104
|
-
compile_php(prefix.to_s)
|
110
|
+
compile_php(php_version, php_download_url, prefix.to_s)
|
105
111
|
|
106
112
|
php_config = prefix.join('bin', 'php-config').to_s
|
107
113
|
find_library('php5', 'php_embed_init', prefix.join('lib').to_s)
|
data/lib/php_embed/version.rb
CHANGED
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: php_embed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- do_aki
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: execute PHP code in Ruby code
|
@@ -72,30 +67,30 @@ files:
|
|
72
67
|
- spec/value_spec.rb
|
73
68
|
homepage: https://github.com/do-aki/php_embed
|
74
69
|
licenses: []
|
70
|
+
metadata: {}
|
75
71
|
post_install_message:
|
76
72
|
rdoc_options: []
|
77
73
|
require_paths:
|
78
74
|
- lib
|
79
75
|
- ext
|
80
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
77
|
requirements:
|
83
|
-
- -
|
78
|
+
- - '>='
|
84
79
|
- !ruby/object:Gem::Version
|
85
80
|
version: '0'
|
86
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
82
|
requirements:
|
89
|
-
- -
|
83
|
+
- - '>='
|
90
84
|
- !ruby/object:Gem::Version
|
91
85
|
version: '0'
|
92
86
|
requirements: []
|
93
87
|
rubyforge_project:
|
94
|
-
rubygems_version:
|
88
|
+
rubygems_version: 2.0.0
|
95
89
|
signing_key:
|
96
|
-
specification_version:
|
90
|
+
specification_version: 4
|
97
91
|
summary: execute PHP code in Ruby code
|
98
92
|
test_files:
|
99
93
|
- spec/php_spec.rb
|
100
94
|
- spec/require.php
|
101
95
|
- spec/value_spec.rb
|
96
|
+
has_rdoc:
|