How to use pear FILE package example - php

Can someone give me example how to use installed pear package, specifically FILE package. I'm php beginner and have never worked with pear so I'm interested in how to use any package after installation...I just call classes and functions from package it self? Second thing that interests me, can I just include downloaded package where ever I need in my files and use it?
Thanks

There are some very good examples linked to from the official File documentation, and yes you pretty much just call those functions and methods in that package from your own code.
The answer to your second question is also "Yes" :-) You can include that package in your code where-ever you need it.

Related

VsCode PHP-Intellisense using composer and autoload.php

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

How to extract config/views while developing a package for composer/packagist?

I am creating a stand-alone package at packagist.org, seen this article and it helped me a lot http://blog.jgrossi.com/2013/creating-your-first-composer-packagist-package/. Can you please help me out how can I generate views/config like I want to extract some files outside the vendor directory when someone install my package from packagist by composer command?
If you want to use views in your PHP package you should choose what view parser you want to use, or you can even create your own, using ob_start(), etc.
I suggest you to take a look how packages do that, maybe checking the Laravel View component. It's not difficult to do that, but once you're creating a package for PHP and not for a specific framework you have to choose how you're going to implement views, just that.
Cheers, JG.

Manual install for PHP API library for Elasticsearch

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.

go-aop-php wont work even with simple setup

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

How to use PHP classes from GitHub?

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

Categories