| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 1 | Thrift PHP Software Library |
| 2 | |
| Robert Lu | 68707d9 | 2018-01-17 19:40:39 +0800 | [diff] [blame] | 3 | # License |
| Bryan Duxbury | def30a6 | 2009-04-08 00:19:37 +0000 | [diff] [blame] | 4 | |
| 5 | Licensed to the Apache Software Foundation (ASF) under one |
| 6 | or more contributor license agreements. See the NOTICE file |
| 7 | distributed with this work for additional information |
| 8 | regarding copyright ownership. The ASF licenses this file |
| 9 | to you under the Apache License, Version 2.0 (the |
| 10 | "License"); you may not use this file except in compliance |
| 11 | with the License. You may obtain a copy of the License at |
| 12 | |
| 13 | http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | |
| 15 | Unless required by applicable law or agreed to in writing, |
| 16 | software distributed under the License is distributed on an |
| 17 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 18 | KIND, either express or implied. See the License for the |
| 19 | specific language governing permissions and limitations |
| 20 | under the License. |
| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 21 | |
| Robert Lu | 68707d9 | 2018-01-17 19:40:39 +0800 | [diff] [blame] | 22 | # Using Thrift with PHP |
| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 23 | |
| vladimir.panivko | f692702 | 2024-02-24 17:12:10 +0100 | [diff] [blame] | 24 | Thrift requires PHP 7.1 Thrift makes as few assumptions about your PHP |
| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 25 | environment as possible while trying to make some more advanced PHP |
| panivko | dfe7f30 | 2020-03-04 15:05:17 +0200 | [diff] [blame] | 26 | features (i.e. APCu cacheing using asbolute path URLs) as simple as possible. |
| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 27 | |
| 28 | To use Thrift in your PHP codebase, take the following steps: |
| 29 | |
| Robert Lu | 68707d9 | 2018-01-17 19:40:39 +0800 | [diff] [blame] | 30 | 1. Copy all of thrift/lib/php/lib into your PHP codebase |
| 31 | 2. Configure Symfony Autoloader (or whatever you usually use) |
| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 32 | |
| jfarrell | aa72161 | 2013-08-02 21:55:22 -0400 | [diff] [blame] | 33 | After that, you have to manually include the Thrift package |
| Roger Meier | 21c0a85 | 2012-09-05 19:47:14 +0000 | [diff] [blame] | 34 | created by the compiler: |
| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 35 | |
| Robert Lu | 68707d9 | 2018-01-17 19:40:39 +0800 | [diff] [blame] | 36 | ``` |
| Roger Meier | 21c0a85 | 2012-09-05 19:47:14 +0000 | [diff] [blame] | 37 | require_once 'packages/Service/Service.php'; |
| 38 | require_once 'packages/Service/Types.php'; |
| Robert Lu | 68707d9 | 2018-01-17 19:40:39 +0800 | [diff] [blame] | 39 | ``` |
| Mark Slee | 54b7ab9 | 2007-03-06 00:06:27 +0000 | [diff] [blame] | 40 | |
| Robert Lu | 68707d9 | 2018-01-17 19:40:39 +0800 | [diff] [blame] | 41 | # Dependencies |
| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 42 | |
| 43 | PHP_INT_SIZE |
| 44 | |
| Robert Lu | 68707d9 | 2018-01-17 19:40:39 +0800 | [diff] [blame] | 45 | 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 Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 48 | |
| panivko | dfe7f30 | 2020-03-04 15:05:17 +0200 | [diff] [blame] | 49 | apcu_fetch(), apcu_store() |
| Mark Slee | 5d06fea | 2007-03-05 22:18:18 +0000 | [diff] [blame] | 50 | |
| panivko | dfe7f30 | 2020-03-04 15:05:17 +0200 | [diff] [blame] | 51 | APCu cache is used by the TSocketPool class. If you do not have APCu installed, |
| Robert Lu | 68707d9 | 2018-01-17 19:40:39 +0800 | [diff] [blame] | 52 | Thrift will fill in null stub function definitions. |
| 53 | |
| 54 | # Breaking Changes |
| 55 | |
| 56 | ## 0.12.0 |
| 57 | |
| 58 | 1. [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 | |
| 60 | 2. If using PSR-4, use `$thriftClassLoader->registerNamespace('namespace', '<path>')` instead of `$thriftClassLoader->registerDefinition('namespace', '<path>')`. |