PHPStorm, Silex DI indices code completion - dependency-injection

I'm trying PHPStorm and have trouble with its code completion. I write project with Silex framework and faced PHPStorm's lack of code completion for Silex dependency injection container. For example, it doesnt codecomplete $app['twig']-> or $app['db']-> or any other service. The only way solution I've found is to do smth like this
$db = $app['db'];
/** #var $db \Doctrine\DBAL\Connection */
$db->....
And then PHPStorm will do code completion. Services are registered using ServiceProvider interface.
Is there a way to make PHPStorm do code completion in such cases without additional vars and comments?

As far as I'm aware, this is currently not possible, however, there is currently work going on to add support for generic factory patterns, see this issue on their issue-tracker:
http://youtrack.jetbrains.com/issue/WI-6027
The PhpStorm developers welcome new feature requests on their issue tracker and are quite responsive. So you may file a feature request
Also, this may be related to your question:
http://youtrack.jetbrains.com/issue/WI-5304

Here's a plugin for PHPStorm / Intellij IDEA:
https://plugins.jetbrains.com/plugin/7809?pr=
Didn't tried it yet, but looks promising...
Edit: Just gave it a quick shot, and it looks really cool and simple to set up:
Install the plugin via the IDE plugin manager
Add the following dependency:
"require": {
"sorien/silex-pimple-dumper": "~1.0"
}
Register the provider:
$app->register(new Sorien\Provider\PimpleDumpProvider());
And you are done.

Related

How to use the erlang-server stubs from OpenAPI generator?

I am currently trying to develop a REST API using Erlang. I used OpenAPI (Swagger) to define the API and wanted to use their openapi-generator to create the stubs and some helper code. This also works and some code is generated, but I cannot find any documentation on what I have to do from there.
For the explanation of my problem, I will refer to their sample output from code generation for erlang-server.
I have two main problems at the moment:
I cannot find an entry point into the code (e.g. a init/0 or start/0 function)
I am not sure which function I have to implement to execute my code on each endpoint. I think that I have to implement handle_request, but the execution path seems a bit weird to me.
Which function to implement
In openapi_router they define openapi_pet_handler to be the handler for 'AddPet'. In that module, there is a function called handle_request_json, which tries to populate the request and in case of OK executes openapi_logic_handler:handle_request(LogicHandler, ...).
openapi_logic_handler:handle_request(Handler, ...) takes that handler and executes Handler:handle_request(OperationID, Req, Context).. This leads me to the conclusion, that I probably have to implement openapi_pet_handler:handle_request with my custom code.
How to start the server
I checked the code and it seems to use cowboy as a web server. At least it includes dependencies to cowboy in the generated openapi.app.src. However, in rebar.config there is no reference to cowboy.
In the cowboy tutorial, they use erlang.mk to build their project. This allows them to run the code with make run. With rebar this does not seem to be possible. I did not find a specific command for rebar to start a program. You seem to have to know the entrypoint (init function) if you use rebar.
However, I am not able to find any function that looks like it could be an init function in the generated stub code.
Summary
Can somebody explain what has to be done to use the stub generated by openapi-generator for erlang-server? Do I have to setup my own cowboy project and then somehow link the stubs into it? If yes, how?

Logger service using logging package in Angular Dart

There is a mention in the docs of using the logging package to create a proper logger service. Given the features in the logging package it would be nice to be able to get the angular component tree as the logger full name.
I tried to play a bit with the dependency injection system to get the injector tree, so that I could reconstruct the app structure for the loggers. But this proved to be too tricky.
Is there a way to do this, or alternatively, is there a canonical logger service that I could use? It seems to be a pretty basic feature so it must be available somewhere.
I'd look at the logging package for help here.
This is not Angular-specific, but it supports tested loggers.

Hp Loadrunner / virtual user generator web click and script alternative

Not sure if iam asking this in the right place, sorry if not!
We currently create scripts through HP Virtual User generator (using the web click and script protocol) to monitor our webapps, we use this as they require JavaScript execution when being monitored. We import these scripts into HP sitescope so we get alerted when they are down.
The issue is after upgrading to loadrunner 12.01 they have removed the web click and script protocol. I have ran the protocol advisor and it advised to use Truclient ajax - IE protocol. I recorded a script using this and it worked great but it looks like this is not supported in sitescope!
Is anyone aware of an alernative to Web click and script that is compatible with sitescope or an alternative to sitescope altogether?
Thanks!
Web virtual user. Recode the JavaScript function you need in C or take advantage of the functions available in LoadRunner to execute your JavaScript "as is"
If you're going to go with Web HTTP, as James suggests, here's the blog post that explains how to integrate JS bits into your script: http://h30499.www3.hp.com/t5/HP-LoadRunner-and-Performance/How-to-use-JavaScript-in-your-HP-LoadRunner-scripts/ba-p/6197321#.VEO-f8ksHRw
They have not removed the click and script protocol. What they've done is rename it to Ajax Click and Script
Ah yes you're right Ajax Click and Script is different from the normal click and script that is no longer available in LR12.
With the Ajax Click & Script have you tried changing the event configuration level? This might help.

Grails: Provide a library to an external groovy script

what I have:
an external GroovyScript using the apache-commons-io library
and a working grails application
In the existing grails-application there are different external scripts (as of now only perl-scripts) which are executed async with grails (using the execute-Method).
Now I got an GroovyScript which I want to run the same way as I run the PerlScripts.
At the moment the script has the commons-io-library in a lib-folder. It works fine.
So my question is: How do I provide the groovy-script with the commons-io-library from grails in a smooth and neat way? Do I have to provide the path within the command which is executed via the execute-Method
e.g.:
groovy -cp=path/to/grailshome/lib.jar scripfile.groovy
this won't really work if I deploy the grailsapplication to the tomcat in the current production-environment as the libs from grails are in a different path.
Putting the script into the src/groovy folder of grails would probably work, but that's not the way I want it. The script needs to be standalone.
I'm really stuck as I'm not really versed with the technical details of and groovy grails.
Even suggestions and ideas how this can be accomplished are enough.
I hope you understand the question, thanks in advance
Is this a situation where using Grapes and putting:
#Grab( 'commons-io:commons-io:2.1' )
At the top of your groovy script would help?
If you are running this as a war, then this might work:
String path = grailsApplication.parentContext
.getResource( 'WEB-INF/lib/commons-io-1.4.jar' )
.file
.absolutePath

Silverlight 3 with Weborb for Java

For some reason, i can not invoke java method deployed under Tomcat/Weborb application. When i run weborb console and invoke the method from there, there is no problem. However when i tried to call from Silverlight 3 client, it does not response at all. There is one possibility which is incorrect service gateway. But i have checked the server path to make sure it is correct. I also tried different approaches to invoke server call such as proxy and class interface mentioned inside weborb documentation. I'm stuck with this problem for two days already and can not progress any further. Is there any common mistake when it comes to this problem? Any help would appreciate.
Cheers,
Khoa Nguyen
I found the solution. This is because the gateway mapping is incorrect. For instance, When deploy under weborb, the client use localhost:8080/weborb.wo. However when you deploy underworb, the gateway mapping is now change to something like localhost:8080/weborb/console/weborb.wo something like that. You can see how your request mapped to by run the weborb console and look at the server status as you invoke your java methods.
Hope this help.
Cheers,
Khoa Nguyen
There is a new WebORB for Java 4.1 release available that fixes this mapping issue. In addition, the new code generator creates a complete client class library with complex types, enums, bindable model and proxy class for the remote Java service. The release is available here:http://www.themidnightcoders.com/products.html

Resources