overblog / thriftbundle Goto Github PK
View Code? Open in Web Editor NEWIntegrate Thrift into Symfony project
License: MIT License
Integrate Thrift into Symfony project
License: MIT License
Is there a way I could add custom HTTP headers for clients using http transport?
If I understand the your bundle correctly, based on the thrift client config it injects instances of Overblog\ThriftBundle\Client\HttpClient
dynamically into the container. If you look at the returned $socket
variable which is an instance of Thrift\Transport\THttpClient
I would simply need to call method addHeaders()
to add custom headers to the request. I have tried finding a way to have your bundle pick up my own class in my AppBundle
that extends your class but the OverblogThrift bundle seems to pull its config directly from its own yml file Resources/config/services.yml
and I have not been able to successfully provide overrides for any of the parameters. I have tried to extend the OverblogThriftBundle
bundle with no luck. I have also tried to overwrite DI container parameters via a Compiler Pass but it seems that the compiler pass happens prior to ThriftBundle/DependencyInjection/OverblogThriftExtension.php
which dynamically adds the client services into the container. Is there a way to overwrite or extend OverblogThriftBundle's HttpClient
class to allow me to add custom headers to the instance of Thrift\Transport\THttpClient
? I am running Symfony version 2.8. Any help regarding how to do this is greatly appreciated!
The "thriftPath" property should be settable in order to work in other environments (ubuntu)
in Compiler\ThriftCompiler
There's a problem with the validation which I've just met.
If you have a neither optional nor required field like 8: i32 level
it is treated optional when reading structs but is treated as required on writing and generates an exception:
if ($this->level === null) {
throw new TProtocolException('Required field PlayerProfile.level is unset!');
}
So practically you can receive such messages but can't send them. ๐
More on this: http://lionet.info/asn1c/blog/2010/07/18/thrift-semantics/
I've checked out the symfony-standard
repo branch 2.6 in order to play with the ThriftBundle.
After I included the bundle into composer.json, updated the code and added a correct thrift.config.compiler.path
, the command "app/console cache:clear" failed with this exception:
[UnexpectedValueException]
RecursiveDirectoryIterator::__construct(/home/wicked/Programming/gitolite/thrift/app/cache/dev/thrift):
failed to open dir: No such file or directory
I think it would be better if the bundle managed to create the dir automatically.
Hello,
I created a bundle called RemoteUserBundle. Then I implemented in it an SSO authentication making use of Thrift as a user provider.
I now want to make this bundle generic, and create another bundle, let's call it MyAppUserBundle. This is the bundle where I override the user entity to add to it some fields and relations.
When I do this and refresh my page, it says that it can't find my Thrift definition into a folder under the new bundle. Why do thrift searches into this one?
It was working perfectly when I only used RemoteUserBundle. It seems that OverblogThriftBundle is attempting to load the thrift definition files from the inheriting bundle of the one declared in the config.yml (bundleNameIn).
Copying the folder to the new bundle fixes the problem.
Since your bundle requires symfony/symfony, it already has access to symfony/process (it's provided by symfony/symfony).
I think you should change the call to exec()
to a ProcessBuilder creation.
Something like this:
diff --git a/Compiler/ThriftCompiler.php b/Compiler/ThriftCompiler.php
index 597c511..155ad65 100644
--- a/Compiler/ThriftCompiler.php
+++ b/Compiler/ThriftCompiler.php
@@ -3,6 +3,7 @@
namespace Overblog\ThriftBundle\Compiler;
use Overblog\ThriftBundle\Exception\ConfigurationException;
+use Symfony\Component\Process\ProcessBuilder;
/**
* Thrift compiler
@@ -155,14 +156,22 @@ class ThriftCompiler
//Reset output
$this->lastOutput = null;
- exec(sprintf('%s -r -v --gen php:%s --out %s %s 2>&1',
- $this->getExecPath(),
- $this->compileOptions(),
- $this->modelPath,
- $definition
- ), $this->lastOutput, $return);
-
- return (0 === $return) ? true : false;
+ $processBuilder = new ProcessBuilder(
+ array(
+ $this->getExecPath(),
+ '-r',
+ '-v',
+ '--gen',
+ sprintf('php:%s', $this->compileOptions()),
+ '--out',
+ $this->modelPath,
+ $definition
+ )
+ );
+ $process = $processBuilder->getProcess();
+ $process->mustRun();
+ $this->lastOutput = $process->getOutput();
+ return $process->isSuccessful();
}
/**
Though I'm not sure should it use mustRun or not. Exceptions are preferrable of course but this would change the compile() method interface.
I've tried to run phpunit tests.
First I couldn't run just the phpunit
, which is usually just enough: it couldn't find the file for require_once $_SERVER['SYMFONY'].'/Symfony/Component/ClassLoader/UniversalClassLoader.php';
.
Then I found the build.xml
file and run it:
wicked@w:~/Alawar/F2P/gitolite/ThriftBundle $ phing -Dws=. prepare phpunit -verbose
Buildfile: /home/wicked/Alawar/F2P/gitolite/ThriftBundle/build.xml
Override ignored for user property phing.file
Override ignored for user property phing.dir
Overriding previous definition of reference to phing.file
parsing buildfile build.xml
Project base dir set to: /home/wicked/Alawar/F2P/gitolite/ThriftBundle
Property ${ws} => .
Build sequence for target 'prepare' is: prepare
Complete build sequence is: prepare clean phpdoc phpcpd pdepend phpcs phpunit
OverblogThriftBundle > prepare:
[echo] Prepare...
Property ${builddir} => ./build
Property ${builddir} => ./build
Property ${builddir} => ./build
[mkdir] Created dir: /home/wicked/Alawar/F2P/gitolite/ThriftBundle/build/logs/coverage
Property ${builddir} => ./build
[mkdir] Created dir: /home/wicked/Alawar/F2P/gitolite/ThriftBundle/build/docs
Property ${ws} => .
[exec] Executing command: git submodule update --init 2>&1
Build sequence for target 'phpunit' is: phpunit
Complete build sequence is: phpunit clean prepare phpdoc phpcpd pdepend phpcs
OverblogThriftBundle > phpunit:
[echo] PHP Unit...
Property ${builddir} => ./build
Property ${builddir} => ./build
Property ${builddir} => ./build
[exec] Executing command: phpunit -c . --log-junit ./build/logs/phpunit.xml --coverage-clover ./build/logs/coverage/clover.xml --coverage-html ./build/logs/coverage/ 2>&1
[exec] PHPUnit 3.7.28 by Sebastian Bergmann.
[exec]
[exec] The Xdebug extension is not loaded. No code coverage will be generated.
[exec]
[exec]
[exec] PHP Fatal error: Class 'ThriftModel\Test\TestServiceClient' not found in /home/wicked/Alawar/F2P/gitolite/ThriftBundle/Factory/ThriftFactory.php on line 68
BUILD FINISHED
Total time: 0.3059 seconds
Am I still missing something? How it's supposed to compile the models prior to run tests?
Looks like a >=2.4
constraint was added to the symfony/symfony
package in a recent commit --> 8724ee5#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780R16. Is there a specific reason for this or can we allow this to be installed on Symfony 2.3 installations as well?
If it helps, here's the output I got when trying to install this bundle on 2.3.42
:
Confim Version:
$ ./app/console --version
Symfony version 2.3.42 - app/dev/debug
Attempted Install:
$ php -d memory_limit=-1 /usr/local/bin/composer.phar require overblog/thrift-bundle --verbose --profile
[snip]
[1391.2MB/132.86s] Your requirements could not be resolved to an installable set of packages.
[1391.2MB/132.86s]
Problem 1
- Installation request for overblog/thrift-bundle ^0.10.0 -> satisfiable by overblog/thrift-bundle[v0.10].
- overblog/thrift-bundle v0.10 requires symfony/symfony ~2.4|~3.0 -> satisfiable by symfony/symfony[2.4.x-dev, 2.5.x-dev, 2.6.x-dev, 2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, v2.4.0, v2.4.0-BETA1, v2.4.0-BETA2, v2.4.0-RC1, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.5.0, v2.5.0-BETA1, v2.5.0-BETA2, v2.5.0-RC1, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.0-BETA1, v2.6.0-BETA2, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.0-BETA1, v2.7.0-BETA2, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.0-BETA1, v2.8.1, v2.8.10, v2.8.11, v2.8.2, v2.8.3, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9, v3.0.0, v3.0.0-BETA1, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.0.7, v3.0.8, v3.0.9, v3.1.0, v3.1.0-BETA1, v3.1.0-RC1, v3.1.1, v3.1.2, v3.1.3, v3.1.4] but these conflict with your requirements or minimum-stability.
I tried to include the Bundle in a fresh installation of Symfony 2.4 and got these errors when trying to update composer:
composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for overblog/thrift-bundle dev-master -> satisfiable by overblog/thrift-bundle[dev-master].
- overblog/thrift-bundle dev-master requires ebuzzing/thrift 0.9.1.x-dev -> no matching package found.
Problem 2
- overblog/thrift-bundle dev-master requires ebuzzing/thrift 0.9.1.x-dev -> no matching package found.
- symfony/framework-standard-edition 2.4.x-dev requires overblog/thrift-bundle dev-master -> satisfiable by overblog/thrift-bundle[dev-master].
- Installation request for symfony/framework-standard-edition 2.4.x-dev -> satisfiable by symfony/framework-standard-edition[2.4.x-dev].
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.