How to install Predis on app service? - php

I am using azure app service My application requires Predis extension to be installed on the server, how can I have it installed on App services? Application is in PHP.

You can package the Predis SDK in your application and deploy to Azure Web Apps Service together via GIT or FTP. Create a PHP-MySQL web app in Azure App Service and deploy using Git for more info.
Additionally, you can just simply configure the Predis SDK in composer.json.
"require": {
"predis/predis": "1.*"
}
Then install the composer extension in your Azure Web Apps Service. Then when you deploying to Azure via Git, the Azure deployment task will run composer install command to install the dependencies and composer commands configured in the file.
You can refer to How to install composer on app service? for installing composer extension
Additionally, if you leverage Redis Cache in Azure, you should Enable the non-SSL endpoint for PHP integration at first:
And the code snippet:
require 'vendor/autoload.php';
$client = new Predis\Client('redis://{your_redis_service_name}.redis.cache.windows.net');
$client->auth('{password key}');
$client->set('foo', 'bar');
$value = $client->get('foo');
echo $value;

Related

Symfony 5 book the fast track: Is redis necessary for installing guestbook

I am trying to launch the "guestbook" web app from the "Symfony 5: the fast track" book. I check that all is well installed by taping the following command:
symfony book:check-requirements
and all is ok.
But when I launch the local web server and the guestbook web site with:
symfony open:local
I got the following error on my web page:
Cannot find the "redis" extension nor the "predis/predis" package
Installation of redis is not mentioned in the book.
I am on Mac Os X Mojave.
Any Idea?
Regards
You need to:
install predis/predis package:
composer require predis/predis
and update your .env.local:
REDIS_URL=redis://localhost:usedPort?timeout=5
Install redis in your library, you can download and read instruction here Redis PECL

Google App Engine composer dependencies do not update

I'm running my PHP application on Google Cloud App Engine Standard. After I deployed a new version of my app with a new composer package, I see that this new package was not installed during the deployment.
I deploy my app with gcloud app deploy. In the Cloud Console Debug tool, I can't find the package in the vendor folder. The package is successfully installed locally.
Is there a trick to update composer packages?
I had this problem too. Turns out this only works for '2nd generation run times'. In other words, your application will need to be PHP7.3. php5 applications will not process composer files.

Deploy a Symfony2 app on cPanel

I'm new to cPanel and I want to deploy my Symfony2 app on it.
I need some guidance on how to do it,
I downloaded the Symfony2 framework with the Softaculous Apps Installer.
PS : My app is also on BitBucket.
First off all: CPanel is just a web-shell arround your linux os that makes it easy to maintain your server from distance through a web interface.
Actualy you do not need softaculous because it just installs an empty new symfony project.
There are globally two ways to install your symfony project.
Install git and Composer on your server, use git to pull the project from bitbucket and install the the vendors with 'composer install' or 'composer update'.
Upload your complete project from your local computer to the server with FTP.
In both ways you still have to install your database and set your configuration.
If you have a shared online server then just copy the entire symfony project through FTP, set up your database credentials in parameters.yml, and manually delete the prod directory inside var (symfony ≥ 2.8) or app (symfony ≤ 2.7).

openshift symfony install third party libraries

I'm trying to add FosUserBundle and HWIOAuthBundle to my symfony project in openshift. In localhost, to add those libraries, I'd to edit composer.json and update the composer.phar. Now I don't know how to update the composer.phar on openshift.
My way(step-by-step):
Create a symfony app from openshift
clone the project to my localhost
edit the composer.json and push it again to openshift
after that, what should I do to update the composer? Or is there another way to add those libraries to the symfony project?
You probably need to setup an action_hook to run the composer command on the openshift server after you do a git push, maybe in the deploy action_hook. Another idea would be to install the libraries locally using composer and then add them into git and push all of it up to the server with a git push and let it all be deployed together. As far as I know composer is not installed on the server, so you may need to install it into your app-root/data directory and call it from there with your deploy hook.
Here is a blog article about using composer with OpenShift: http://stanlemon.net/2013/03/22/composer-on-openshift/ that might help answer your question

How do I install Ratchet WebSockets for PHP on MAMP or XAMPP?

I'm trying to integrate a real time chat into my php / backbone app and I thought I would use ratchet? What do I need to do to install Ratchet into MAMP or XAMPP? The only documentation provided on their website is to use CURL, but I don't know how to install the necessary resources for localhost, nor do I know where those resources need to be add to. Any advice would be appreciated.
You should install composer.phar in the root directory of your project.
If you are on linux you could simply run the command curl -s https://getcomposer.org/installer | php, otherwise you could use the windows installer from curl's download page
Once you have installed composer you have to create a 'composer.json' file where you will add all the dependencies needed for your project. If you only need Ratchet just paste this into your json file:
{
"require": {
"cboden/Ratchet": "0.2.*"
}
}
Once you have done that, return to your terminal and run the command php composer.phar install.
This will install Ratchet and its dependencies on a newly created 'vendor' folder.
Now you could include Rathet in your php file in this way:
require __DIR__ . '/vendor/autoload.php';
That's all I think!
cURL is enabled by default in MAMP and XAMPP, and the MAMP & XAMPP are just web server + database server serving PHP . You can just install Ratchet WebSockets just like you deploy to live web server.
But make sure you are calling the correct php executable, instead of the one you might be installed on your computer / server .
See: http://socketo.me/docs/install

Categories