• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

lib/11-Mar-2024-8,2454,701

src/11-Mar-2024-2,2971,884

test/11-Mar-2024-1,6171,017

Makefile.amD11-Mar-20244.8 KiB167122

README.apache.mdD11-Mar-20242 KiB7555

README.mdD11-Mar-20242 KiB6141

coding_standards.mdD11-Mar-2024149 64

thrift_protocol.iniD11-Mar-202429 21

README.apache.md

1Thrift PHP/Apache Integration
2
3License
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.
22
23Building PHP Thrift Services with Apache
24========================================
25
26Thrift can be embedded in the Apache webserver with PHP installed. Sample
27code is provided below. Note that to make requests to this type of server
28you must use a THttpClient transport.
29
30Sample Code
31===========
32
33<?php
34
35namespace MyNamespace;
36
37/**
38 * Include path
39 */
40$THRIFT_ROOT = '/your/thrift/root/lib';
41
42/**
43 * Init Autloader
44 */
45require_once $THRIFT_ROOT . '/Thrift/ClassLoader/ThriftClassLoader.php';
46
47$loader = new ThriftClassLoader();
48$loader->registerNamespace('Thrift', $THRIFT_ROOT);
49$loader->registerDefinition('Thrift', $THRIFT_ROOT . '/packages');
50$loader->register();
51
52use Thrift\Transport\TPhpStream;
53use Thrift\Protocol\TBinaryProtocol;
54
55/**
56 * Example of how to build a Thrift server in Apache/PHP
57 */
58
59class ServiceHandler implements ServiceIf {
60  // Implement your interface and methods here
61}
62
63header('Content-Type: application/x-thrift');
64
65$handler = new ServiceHandler();
66$processor = new ServiceProcessor($handler);
67
68// Use the TPhpStream transport to read/write directly from HTTP
69$transport = new TPhpStream(TPhpStream::MODE_R | TPhpStream::MODE_W);
70$protocol = new TBinaryProtocol($transport);
71
72$transport->open();
73$processor->process($protocol, $protocol);
74$transport->close();
75

README.md

1Thrift PHP Software Library
2
3# License
4
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.
21
22# Using Thrift with PHP
23
24Thrift requires PHP 5. Thrift makes as few assumptions about your PHP
25environment as possible while trying to make some more advanced PHP
26features (i.e. APCu cacheing using asbolute path URLs) as simple as possible.
27
28To use Thrift in your PHP codebase, take the following steps:
29
301. Copy all of thrift/lib/php/lib into your PHP codebase
312. Configure Symfony Autoloader (or whatever you usually use)
32
33After that, you have to manually include the Thrift package
34created by the compiler:
35
36```
37require_once 'packages/Service/Service.php';
38require_once 'packages/Service/Types.php';
39```
40
41# Dependencies
42
43PHP_INT_SIZE
44
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.
48
49apcu_fetch(), apcu_store()
50
51    APCu cache is used by the TSocketPool class. If you do not have APCu installed,
52    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>')`.
61