Using "PHP Cache" without Composer - php

I found a PHP caching library that I'd like to use in CodeIgniter, but the docs only have instructions for installing / using with composer: http://www.php-cache.com/en/latest/
I inherited a project on a server that doesn't have Composer. Ideally I would like to use it without Composer. Does anyone have any knowledge of how to load this without it?

well, you could download the package itself and add it to your Codeignitter libraries autoload (if that's possible, sorry, dont know too much of CodeIgnitter). Though if i'd be you i'd go into Composer, it is revolutionary for php apps and you're loosing out so much by not using it... just composer init in main app folder & make sure that your CI is reading the autoloaded classes (i bet you'll find some tutorial for that)
by download I mean download and require in your php files where you're using it!

Related

How to use Plivo PHP helper libraries without composer

I'm trying to use the Plivo PHP helper library in my project, but looks like the only way to use it is with Composer. Is there any work around for this since I cannot use composer in my project as it would change the existing code?
Plivo Sales Engineer here.
Unfortunately, Plivo-PHP helper library can be used only with Composer. If installing the library with Composer is not feasible, you could download and install the dependencies individually and include the libraries in your project. Or, you could also make HTTP requests to the API directly without using the helper library. You could use cURL or Requests library to make these requests.
I had a similar issue.
The access to the server was very limited, I had only FTP access, I could have waited to ask for SSH access to do the install using composer I simply installed Composer on my local machine and then just had to run
composer require plivo/php-sdk
In an empty directory. It created the SDK files under /vendor and I uploaded those files through FTP to the server. Did the job for me.

UserFrosting, Composer & wrong path in includeJSTop

I recently started learning UserFrosting...
I managed to successfully install highlightjs from Packagist using Composer. All went well, new folder and all required files are created in /userfrosting/vendor/components/highlightjs
However, initialize.php and it's includeJSTop() does inject the reference in a path pointing to /public_html/js while files are in /userfrosting/vendor/components/highlightjs
There is a simple solution - to copy highlightjs.js from /userfrosting/vendor/components/highlightjs to /public_html/js but I would like to know if my approach is correct. Or perhaps there is a better way where files are copied to /public_html/js as a part of Composer's install/update.
Composer is for PHP packages. highlight.js is a Javascript package, so it doesn't really make sense to load it using Composer.
There are package managers for Javascript - NPM being the most popular - but UserFrosting 0.3.1 doesn't use those out of the box (UF4 will have integrations for NPM, but that hasn't been released as of the time of this post).
Your best bet for now would indeed be to simply do a "manual install" and copy the highlight.js file to your public/js directory. In that case, you don't need to load it with Composer.

Beginner trouble understanding composer and frameworks

im having a really big problem understanding the usage of composer and frameworks.
The tutorials i have seen use some kind of online-editor so they dont really help me.
I learned about OOP etc and now i want to do the next step and learn about frameworks and composer.
I have a server and already managed to install composer. Plus i managed to install packages.
But what now? Can you tell me at a very basic level how to make use of this stuff?
I have an editor on my notebook and installed composer on my server. How do I interact with the classes?
Do i just write them and upload the file to check if it works? Do i somehow install them on my local environment? And if yes, how would i deploy my project afterwards?
I know its much but im not getting the basics of usage here :(
Thank you very much!
I watched tutorial for hours now but they always just seem to use the stuff. And i dont know how.
What you have to understand is that Composer is only a package manager, it will allow you to download some libraries (and their dependencies), and provide you an autoloader file to include on your files, so that you can use library classes.
Actually, you better install Composer on your local machine, develop your website locally, then, when it's ready, deploy it to your server.
A simple example, supposing you want to use Silex microframework.
Install Silex with composer
composer require 'silex/silex:1.3.0'
Include Silex in your script
Including Composer autoloader file
<?php
require_once './vendor/autoload.php';
$app = new Silex\Application();
?>
Develop
It's up to you, test it locally with a webserver installed on your computer.
Deploy
Deploy your website by pushing it on your webserver (with a FTP client for example).

Using composer installed library, class not found error

I used composer to download a php bitcoin library to play around with. https://github.com/phramz/php-bitcoin-api
This one specifically.
Anyways, everytime I try to use the library with
use Phramz\Bitcoin\Api\Connection\BuzzConnection;
use Phramz\Bitcoin\Api\BitcoindClient;
I get
Interface 'Phramz\Bitcoin\Api\Client' not found in
/root/vendor/phramz/php-bitcoin-api/src/Phramz/Bitcoin/Api/BitcoindClient.php
whenever I try to run any test code. I really want to play around with this library but Im sort of a newbie php programmer and this is frustrating me. Any help would be appreciated!
Make sure you require vendor/autoload.php as described in Composer documentation.
If Composer's vendor directory is not located in the current directory you'll need to use an absolute path or something like:
<?php
require_once(__DIR__."/../../vendor/autoload.php");
I had the kind of issue when I installed a new lib, and i just deployed the new lib to server only as I was new to PHP, it took me hours to figure out that the vendor/composer folder is updated when we install a new lib.
So if your server doesn't support composer install , upload the whole vendor folder to your server is the way.

Issue when using a package (pagseguro/php) with composer in a laravel app, apparently it is not loading or initializing itself

I have a laravel app and i want to use the pagseguro/php package.
I added it to the composer.json and updated. I can access the main class (PagSeguroPaymentRequest) without a problem.
At some point I have to call this:
PagSeguroConfig::getAccountCredentials();
But it throws an exception. After reading code around I thought on trying to init the library by myself and suddenly everything worked:
PagSeguroLibrary::init();
This method is inside the only php file in source/PagSeguroLibrary/
Shouldn't composer automatically execute this method? What is exactly "loading" a package? Is there anyway to fix this using composer only?
Thank you all.
Shouldn't composer automatically execute this method?
No, it shouldn't. Composer is a package and dependency manager program. It's job is to
Get PHP files into your vendor folder
If using those PHP files means you need other PHP files, get those other PHP files into your vendor folder
Setup things so that class files from the packages are correctly autoloaded in PHP (i.e. no need to require or include stuff yourself)
Composer packages work independent of frameworks. Someone could distribute a laravel service provider via a computer package, or someone could distribute code that doesn't know anything about Laravel. How each composer package works is up to the author (always read the README)
In the case of pagseguro/php, it looks like you're supposed to instantiate a PagSeguroPaymentRequest object which, when autoloaded, will automatically call init. The examples distributed with the package also makes it look like this package was code that predated composer, and still uses many manual includes and requires.

Categories