blob: e7144fe444e37adaa7cbfbad36ecd0b46d3ca701 [file] [log] [blame] [view]
Mark Slee5d06fea2007-03-05 22:18:18 +00001Thrift PHP Software Library
2
Robert Lu68707d92018-01-17 19:40:39 +08003# License
Bryan Duxburydef30a62009-04-08 00:19:37 +00004
5Licensed to the Apache Software Foundation (ASF) under one
6or more contributor license agreements. See the NOTICE file
7distributed with this work for additional information
8regarding copyright ownership. The ASF licenses this file
9to you under the Apache License, Version 2.0 (the
10"License"); you may not use this file except in compliance
11with the License. You may obtain a copy of the License at
12
13 http://www.apache.org/licenses/LICENSE-2.0
14
15Unless required by applicable law or agreed to in writing,
16software distributed under the License is distributed on an
17"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18KIND, either express or implied. See the License for the
19specific language governing permissions and limitations
20under the License.
Mark Slee5d06fea2007-03-05 22:18:18 +000021
Robert Lu68707d92018-01-17 19:40:39 +080022# Using Thrift with PHP
Mark Slee5d06fea2007-03-05 22:18:18 +000023
24Thrift requires PHP 5. Thrift makes as few assumptions about your PHP
25environment as possible while trying to make some more advanced PHP
panivkodfe7f302020-03-04 15:05:17 +020026features (i.e. APCu cacheing using asbolute path URLs) as simple as possible.
Mark Slee5d06fea2007-03-05 22:18:18 +000027
28To use Thrift in your PHP codebase, take the following steps:
29
Robert Lu68707d92018-01-17 19:40:39 +0800301. Copy all of thrift/lib/php/lib into your PHP codebase
312. Configure Symfony Autoloader (or whatever you usually use)
Mark Slee5d06fea2007-03-05 22:18:18 +000032
jfarrellaa721612013-08-02 21:55:22 -040033After that, you have to manually include the Thrift package
Roger Meier21c0a852012-09-05 19:47:14 +000034created by the compiler:
Mark Slee5d06fea2007-03-05 22:18:18 +000035
Robert Lu68707d92018-01-17 19:40:39 +080036```
Roger Meier21c0a852012-09-05 19:47:14 +000037require_once 'packages/Service/Service.php';
38require_once 'packages/Service/Types.php';
Robert Lu68707d92018-01-17 19:40:39 +080039```
Mark Slee54b7ab92007-03-06 00:06:27 +000040
Robert Lu68707d92018-01-17 19:40:39 +080041# Dependencies
Mark Slee5d06fea2007-03-05 22:18:18 +000042
43PHP_INT_SIZE
44
Robert Lu68707d92018-01-17 19:40:39 +080045 This built-in signals whether your architecture is 32 or 64 bit and is
46 used by the TBinaryProtocol to properly use pack() and unpack() to
47 serialize data.
Mark Slee5d06fea2007-03-05 22:18:18 +000048
panivkodfe7f302020-03-04 15:05:17 +020049apcu_fetch(), apcu_store()
Mark Slee5d06fea2007-03-05 22:18:18 +000050
panivkodfe7f302020-03-04 15:05:17 +020051 APCu cache is used by the TSocketPool class. If you do not have APCu installed,
Robert Lu68707d92018-01-17 19:40:39 +080052 Thrift will fill in null stub function definitions.
53
54# Breaking Changes
55
56## 0.12.0
57
581. [PSR-4](https://www.php-fig.org/psr/psr-4/) loader is now the default. If you want to use class maps instead, use `-gen php:classmap`.
59
602. If using PSR-4, use `$thriftClassLoader->registerNamespace('namespace', '<path>')` instead of `$thriftClassLoader->registerDefinition('namespace', '<path>')`.