I cant seem to make go-aop-php library work for me and I have no idea why.
Basically I have go-aop-php 0.6.0 installed with composer and simple code which I ripped off from the available examples.
Here's the GIST of my code.
Attached below is the directory structure (if it's of any help):
I am running Ubuntu 14.04 with PHP 5.5. I am also wondering if I missed any dependencies for go-aop-php to operate properly.
Go! AOP is not a magic tool and can not change already loaded class to weave an aspect into it. In your case you explicitly load class via direct require_once __DIR__.'/classes/TestClass.php'; expression. After that class is already loaded and AOP won't be applied.
To fix your issue, you should use a composer for class autoloading (Go! AOP intercepts this automatically).
PS. If you will have any questions or need a support, please open an issue on GitHub instead. StackOverflow isn't a place to discuss such issues. I will be glad to help you with any issues on GitHub
Related
I am using composer for dependency-management in a new Php-Project.
I plan to just use the autoload.php of composer to include/require the external libraries.
My problem is, that VsCode isn't able to recognize which files would get included via the autoload, and so it doesn't provide me with any intellisense/code-completion-features related to the libraries.
Does anybody have a solution/workaround for this problem, that would give me the desired features?
okay, right after posting my question, i found a simple solution, in form of an extension.
It is called intelephense. You might want to take a look at it in the marketplace:
https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client
I downloaded this php api package from github
https://github.com/elastic/elasticsearch-php/tree/2.0
but I am having a hard time installing it. I unfortunately dont have permission to use the composer/auto-loader from where I work so I have to do it manually. Is there a way of doing this?
Thanks for your help.
The classes look pretty well formatted PSR-4 so you should be able to just download the directorysrc/Elasticsearch, and make a simple autoloader of your own and register it (assuming you don't already have one setup to serve classes that adhere to PSR-4).
Here's some options: http://www.php-fig.org/psr/psr-4/examples/
All the other directories seem to to be extraneous to running of the classes--for unit testing and benchmarking.
I am trying to do some PDF form filling. I found this PHP library:
https://github.com/mikehaertl/php-pdftk
However, I have never installed libraries before and am not sure how to proceed. I already have pdftk installed on the server. I read about autoload, and am familiar with functions like require_once, etc, but I am really not sure how to properly go about this. Any help is appreciated!
Regards
Hard to say without seeing the project but if there are a ton of files then there is probably 1 that is using the rest as dependencies. What I mean by that is that there should be 1 file that you can require_once. See if there is a readme. That's usually my first step.
I don't know this particular library, but usually it is just enough to require_once on the library's main class.
Edit: The library uses Composer to resolve its dependencies. You could do the same: https://getcomposer.org
Adding Httpful (http://phphttpclient.com/) to ATK4 using the recommended Composer method does not work.
After some fooling around I managed to get all the file paths correct but I get "Fatal error: Class 'Frontend' not found in /var/www/portal/index.php on line 14".
Using the 'phar' method described on Httpful's page is also a no-go.
I don't know if this needs to be implemented through an add-on, and if it does, I don't know how. Any info/pointers would be appreciated...
The bottom line is: I need to interact with a REST API in a sane way, it doesn't have to be Httpful specifically, is there another solution out there that someone has already implemented in ATK4?
Please look into this repository which is designed to run Agile Toolkit based on composer primarily:
https://github.com/atk4/atk4-secure/
You can also look at this branch:
https://github.com/atk4/atk4/tree/4.3-PageManager-refactoring
which deals with this issue:
https://github.com/atk4/atk4/issues/403
although that's not part of the "master" branch, instead it went to 4.3. Perhaps you can back-port the commits.
Edit: I must also mention, that this should work best if you have picked Agile Toolkit from Git repository.
I played with the zf2-tutorial successfully, but I was totally confused when trying to integrate an external library like "jpgraph". I know I must do this with autoload or servicemanager but it won't work.
The php-files of jpgraph are in the vendor/graph directory. I use a module called Jpgraph, in the controller indexAction I try:
$graph = new Graph($width,$height);
this gives me an error:
Fatal error: Class 'Jpgraph\Controller\Graph' not found in ...
the jpgraph library don't use namespaces.
i also tried this way without success
what's the best way to integrate such things?
I would be glad for every tip or help
Add the library to your composer.json and add the class with Classmap and/or the include path as phpunit does
https://github.com/sebastianbergmann/phpunit/blob/master/composer.json#L48
One option, as Maks3w pointed out, is to use Composer. If you've never heard of or used composer before it's definitely worth a look. I was surprised how easy it was to set up and use 3rd party libraries. It's also very easy to set up your own library to work with composer, and use any source controlled (git or svn) library of your own - works well with GitHub repos - just add a composer.json file.
On the other hand, you do not need to use composer to do what you want, it would make it very easy, but it may be overkill. Zend Framework 2 has a very flexible autoloader system, and although it works well with PSR-0, you can have any class autoloading sytem that you like. Take a look at the different components of Zend\Loader, in particular I think the ClassMapAutoloader will be the one to suit your needs.