I made a WP plugin which depends on the Youtube API. So, to do it well, I use Google API PHP client.
My issue is quite simple: the Google API PHP client is huge (more than 12 000 files), including clients for all Google services, when I just need to use Youtube service. So I'm not confortable committing all those files to the WP plugins repo when most of them are useless in my case.
So, right now, my composer.json looks like this:
{
"require": {
"google/apiclient": "^2.0"
}
}
Any way to use only the Youtube API client (using composer if it's possible)?
This is not for the feign of heart but it is doable.
Go to this branch of the repo https://github.com/google/google-api-php-client/tree/v1-master
Grab the full src/Google directory you will need all of that.
In the src/Google/Service directory is the stuff for all the different APIs. Remove everything except for YouTube.
cross your fingers it should work.
This wont remove all 12000 files but it should give you just what you absolutely need. I used to do this but its been a few years.
Unfortunately, I don't think this is possible without manually including the relevant files in your project (which is a really bad idea).
The reason why its impossible, is because Google places all service APIs for the PHP library in a single GitHub repository found here:
https://github.com/google/google-api-php-client-services
If Google does split them into multiple repositories, then it could be possible to include a single repo.
For now, though, all services are under one composer project and one repo. Maybe its worth making a GitHub issue to ask Google about this?
Related
I'm building DMS (Document management system) using PHP framework Laravel.
One of the requirements is allowing users to version control files, close to what google docs does.
I've been searching for days without any clue, I don't want to re-impalement the wheel, there's a lot of really good VCS already including git which I'm thinking of utilizing it using php to implement the versioning features.
I just don't know how to start or even my way of thinking is valid!
What you need is real-time system (achieved via socket programming) so that everyone is updated about the contents in realtime; also who is doing what: Like if there are two users A and B and they have opened the same file then A should know what the B is doing and vice versa; you would use client events for that. Have a look here:
https://laracasts.com/series/get-real-with-laravel-echo
Or
Look into Web RTC: https://webrtc.org/
GIT is a different thing given your requirements what I understood.
I would like to know is there a simple way to reduce the AWS PHP SDK to use only S3 ? I tried to delete certain directory but there are so many it will take an incredible time, and I have many errors depending on the files I delete (21,6Mo - 2 368 elements) ?! Is it possible to know the architecture of the basic files necessary to use only S3 with the SDK PHP please?
I found old posts on this subject but the file structure has changed and they are no longer current.
The complete SDK is very heavy with a lot of files that I don't need to keep my sources with an optimization in reasonable size.
Thanks for your help
Unfortunately to use the SDK you will need to use the entire directory (and all of its individual dependencies).
Whilst you could prune individual directories and files you would then be responsible for maintaining this, including new features which may require additional classes
Best practice for pulling in the SDK is to use the composer dependency manager.
If you were looking for a lighter version you would need to look for someone else's implementation or look at implementing your own library to interact with the AWS S3 API endpoints.
The SDK itself now has a (beta) feature to help you out. Check out https://github.com/aws/aws-sdk-php/tree/master/src/Script/Composer
Basically you require the framework with composer, then specify a script to remove unused services, then define the services you want to keep based on their root namespace.
The example from the page is given below
{
"require": {
"aws/aws-sdk-php": "<version here>"
},
"scripts": {
"pre-autoload-dump": "Aws\\Script\\Composer\\Composer::removeUnusedServices"
},
"extra": {
"aws/aws-sdk-php": [
"Ec2",
"CloudWatch"
]
}
}
Nicolas and Chris,
A Wordpress plugin-related blog entry led me to this S3 SDK Git project by developer Ian Jones that may help resolve this for you, or others in future. The blog article explains the background and reasoning behind the code.
It's a script he wrote for downloading the AWS PHP SDK v3, stripping it down to the relevant S3 functionality, and then applying a custom namespace to avoid potential clashes.
Hoping to try this myself soon, but also for use with the Rekognition API (but I'm at beginner level!).
https://gist.github.com/ianmjones/55eb1ace80517f951e392b95a65f277b
Regards,
Graham
I would highly recommend https://async-aws.com/. You can install each component separately. Maybe it not cover every AWS feature, but S3 is supported for years.
I want to be able to use the Google API with PHP, but I don't want to have to include all 23MB and 8,000+ files. I only really need the Sheets and Drive functionality (for now), but autoload seems to insist I include everything.
Because of what I'm using it for, running Composer I think isn't feasible and I've never managed to get composer working with XAMPP anyway.
Help appreciated.
Check your directory structure you should have something like "Google/Service" look inside. There is a class for each of the Google APIs. Unless you are using every single one of the Google APIs you dont need all of these files. You can remove all but the one API you are going to be using.
That is the extent of what files you can safely remove everything else is needed.
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.
Not sure if this should be here or on Programmers.
Generating API documents
I would like some advice on how I should generate API documentation for an internal project. I am relatively new to Git and we are trying to implement some sound build/deploying practices.
One of the things we discussed was making sure our code base is well documented and generating documentation using something like PhpDocumentor2 or one of the many similar tools.
We have started to implement a workflow similar to the one detailed here.
Should I automate when the docs are built?
For example a pre or post commit hook in git when tagging a release. Or should when I merge develop to a release branch just manually create the docs and commit to the repository?
Is it standard practice to have docs generated for each release?
I might have misunderstood the process, should a new doc release correlate with a git release/tag?
Where do you store the generated docs?
In the same repository? a different repository? Hosted somewhere like Read The Docs or just internally?
The current project we are working on is only small, but we would like to roll out the process to other larger projects in the future if successful.
Context
The project is a Magento extension which we would like to provide API docs, unit testing, and PSR conforming code. I am lacking information on how the whole workflow integrates. PHPunit and PHPDocumentor2 are installed locally via Composer.
I have heard and looked at Travis Ci, but I'm not sure if Docs fall in to that category.
This question may seem petty and/or trivial, however, I've not much experience in integration and git workflow and I couldn't find much information around.
Generated documented generally are:
always in sync with the code source (so the question of "should a new doc release correlate with a git release/tag" becomes moot)
not stored in a version control referential (like a git repo), but rather (re-)generated at will (in any location you like).
If you look at a project with a large code source, and an extensive code documentation, you can take as an example the language Go and his repository (a mercurial repo, but you have mirror on GitHub as well)
static documentations like the specs, articles, release notes, ... are kepts within the repo, as they are not generated, but updated manually, and are tightly linked to the sources.
Code documentation is kept separately in a static web site.
Documentation for all go project is kept in a static website GoDoc, which will fetch the sources of Go projects, and generate the documentation from them.