blob: bb566f42a4761421d44952a4406370ccc2b656fd [file] [log] [blame]
Mark Slee5d06fea2007-03-05 22:18:18 +00001Thrift PHP Software Library
2
Bryan Duxburydef30a62009-04-08 00:19:37 +00003License
4=======
5
6Licensed to the Apache Software Foundation (ASF) under one
7or more contributor license agreements. See the NOTICE file
8distributed with this work for additional information
9regarding copyright ownership. The ASF licenses this file
10to you under the Apache License, Version 2.0 (the
11"License"); you may not use this file except in compliance
12with the License. You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing,
17software distributed under the License is distributed on an
18"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19KIND, either express or implied. See the License for the
20specific language governing permissions and limitations
21under the License.
Mark Slee5d06fea2007-03-05 22:18:18 +000022
23Using Thrift with PHP
24=====================
25
26Thrift requires PHP 5. Thrift makes as few assumptions about your PHP
27environment as possible while trying to make some more advanced PHP
28features (i.e. APC cacheing using asbolute path URLs) as simple as possible.
29
30To use Thrift in your PHP codebase, take the following steps:
31
32#1) Copy all of thrift/lib/php/src into your PHP codebase
33#2) Set $GLOBALS['THRIFT_ROOT'] to the path you installed Thrift
34#3) include_once $GLOBALS['THRIFT_ROOT'].'/Thrift.php';
35
36Note that #3 must be done before including any other Thrift files.
37If you do not do #2, Thrift.php will set this global for you, but it will be
38done using dirname(__FILE__), which is less efficient than providing the static
39string yourself.
40
Mark Slee54b7ab92007-03-06 00:06:27 +000041When you generate a Thrift package using the compiler, it makes an assumption
42about where your generated code will live. If your file is "MyPackage.thrift",
43the generated files must be installed into:
44
45$GLOBALS['THRIFT_ROOT'].'/packages/MyPackage/';
46
47This allows the code generator to compile your code without any extra flags
48for the target directory names while still allowing your include paths to
49be absolute (if you have an absolute THRIFT_ROOT).
50
Mark Slee5d06fea2007-03-05 22:18:18 +000051Dependencies
52============
53
54PHP_INT_SIZE
55
56 This built-in signals whether your architecture is 32 or 64 bit and is
57 used by the TBinaryProtocol to properly use pack() and unpack() to
58 serialize data.
59
60apc_fetch(), apc_store()
61
62 APC cache is used by the TSocketPool class. If you do not have APC installed,
63 Thrift will fill in null stub function definitions.