beanstalkd driver configuration error in laravel app - php

I am trying to use beanstalkd as the queue driver for my laravel app. I am getting this error when I am trying to push something on the queue.
Pheanstalk_Exception_ConnectionException
Socket error 111: Connection refused (connecting to localhost:11300)
Please note that in 'queue.php' I have just changed the default driver to 'beanstalkd' but haven't changed any settings for the driver. The settings for the driver are as follows-
'beanstalkd' => array(
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
),
Please help me with this.

Figured it out. Did these two things -
$ sudo vim /etc/default/beanstalkd
> START yes # uncomment
$ sudo service beanstalkd start
# Alternatively: /etc/init.d/beanstalkd start
Got it from this link - http://fideloper.com/ubuntu-beanstalkd-and-laravel4

The answer by #halkujabra is correct. The error is because beanstalkd is not running. To fix it you just have to start beanstalkd. For MacOS use this script https://gist.github.com/finger-berlin/1942295 to to that.
Download and save it as script.sh
Make it executable: chmod a+x script.sh
Run ./script.sh start

Related

Cannot find save handler 'redis' - Ubuntu

I am running LAMPP on ubuntu with PHP 5.6.23.
I decided to store my sessions in the Redis and I installed it. I also installed Predis too.
As a searched in the web I changed my php.ini to :
session.save_handler = redis
session.save_path = "127.0.0.1:6379"
But when tried create a session I am taking this error:
Warning: session_start(): Cannot find save handler 'redis' - session startup failed in /path/to/the/Untitled.php
You can think that there is a problem in Redis but it's not. It's working properly I can set something and I can check it with Redis-CLI :
My redis 'set' PHP code is :
<?php
require "predis/autoload.php";
$redis = new Predis\Client([
'scheme' => 'tcp',
'host' => '127.0.0.1',
'port' => 6379,
]);
$redis->set('x', '42');
$redis->set('name','test');
?>
Results in telnet:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
MONITOR
+OK
KEYS *
+1471853424.389215 [0 127.0.0.1:36912] "KEYS" "*"
*2
$4
name
$1
x
Session php code:
<?php
session_start();
$count = isset($_SESSION['cont']) ? $_SESSION['cont'] : 1;
echo $count;
$_SESSION['cont'] = ++$count;
?>
It must increase the number every refresh but It just displays an error.
I re-Installed Redis again (v 3.2.3) but still no difference.
Is there any way to solve it?
Could LAMPP be the reason of problem?
EDIT:
I started to use phpredis instead of predis.
You try different things. Predis is a direct client to your Redis Server. If you want to use them as your session handler you have to install the php module.
sudo apt-get install php5-redis
or for PHP7
sudo apt-get install php7.0-redis
Then "redis" should be available as session handler.

Laravel 5 with Postgres SQL

I’m working on Laravel 5 with postgres as database. I’ve configured postgres 9.4 and pgAdmin III and these are working normally. When I try to run migrate it is giving me error:
[PDOException]
could not find driver
This is my database.php
'default' => 'pgsql',
'pgsql' => [ 'driver' => 'pgsql',
'host' => '127.0.0.1',
'database' => 'fms',
'username' => 'postgres',
'password' => 'root',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public', ],
Initially I though, it was due to configuration of postgres on windows 7 but I tried with plain php it works perfect
<?php
$host = "host=127.0.0.1";
$port = "port=5432";
$dbname = "dbname=fms";
$db = pg_connect( "$host $port $dbname user=postgres password=root" );
if(!$db){
echo "Error : Unable to open database\n";
} else {
echo "Opened database successfully\n";
}
?>
I’ve enabled php_pgsql and php_pdo_sql in wamp as well. I’m not sure how to fix this on laravel 5.
As you said you already choosed Default Database as Postgres SQL
'default' => 'pgsql',
It is a must that you need to uncomment the pdo and postgres shared object in your php configuration settings (php.ini)
i.e., You need to uncomment the following lines in your php.ini
extension=pdo_pgsql.so
extension=pgsql.so
Note :
Don't forget to stop and start your apache after doing this changes (or php-fpm if using that instead).
I had the same problem with Laravel-WAMP-PostgreSql driver not found exception. I even successfully established direct connection to Postgre as you have, but with no luck with the "php artisan migrate" command.
After long research I found out that there are multiple php.ini files in which "extension=php_pdo_pgsql.dll" and "extension=php_pgsql.dll" are comented out.
The solution is (of course) to uncoment the extensions in the following files:
~/wamp/bin/php/php5.5.*/php.ini
~/wamp/bin/php/php5.5.*/phpForApache
~/wamp/bin/php/php5.5.*/php.ini.install
~/wamp/bin/php/php5.5.*/php.ini-development
~/wamp/bin/php/php5.5.*/php.ini-production
and
~/wamp/bin/apache/apache2.4.9/php.ini
** You can leave off the "php.ini-development" and "php.ini-production" (don't need to uncoment these files).
Like #jeff said, this is probably caused by not setting DB_CONNECTION=pgsql in the .env-file. The .env-file has MySQL preconfigured, so you must edit this file.
You have to make DB related changes in
config/database.php
.env file
and other settings in
php.ini settings
If you are still getting error, then clear cache and config
php artisan cache:clear
php artisan config:clear
It should work now!
Run this command to easily uncomment the lines extension=pdo_pgsql.so and extension=pgsql.so from php.ini
sed -ri -e 's!;extension=pdo_pgsql!extension=pdo_pgsql!' $PHP_INI_DIR/php.ini
sed -ri -e 's!;extension=pgsql!extension=pgsql!' $PHP_INI_DIR/php.ini
If you do not have the drivers already installed, or it gives error like unable to load dynamic library PGSQL run this:
apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo pgsql pdo_pgsql
This will install the pgsql and pdo_pgsql drivers.
you gotta modify .env file , then go to config>database.php and change the default to pgsql, and also in all your models file you need to change $protected $connection= 'pgsql'.
I'm using PHP7.3 and this worked for me, I forgot this:
apt-get install php7.3-pgsql
Everything runs smoothly afterwards. Just use whatever version of PHP you are using.

Make Laravel artisan play with vagrant from localhost

When I ssh into my local vagrant machine I can execute all artisan commands. Hower outside of it, any commands that needs database access such as artisan migrate gives Access denied for user 'root'#'localhost'. If it is possible, how can I use artisan without having to log in to the vagrant machine?
I would also like to do for example Artisian::call('migrate') for example during testing. But that gives the same error.
The reason for the access denied error is that mysql by default limits access to databases to the local machine. It is possible to open up for remote connections as described here, but it wouldn't be a good idea for production environments.
A better way is to add aliases for the commands you want as described here.
For doing calls to artisan etc in code, Laravel has a built in way of running commands on remote servers. First add connection information to the app/config/remote.php file. For vagrant it should look something like this:
'connections' => array(
'production' => array(
'host' => 'localhost',
'username' => 'vagrant',
'password' => 'vagrant',
'key' => '',
'keyphrase' => '',
'root' => '/vagrant',
),
),
Then execute artisan migrate like this:
SSH::run(array('cd /vagrant', 'php artisan migrate'));
You can do more advanced things as well. Here is the documentation.

Connect Laravel on ubuntu to Azure SQL Server

I am developing an laravel app using ubuntu as OS and my database is in a remote Azure Server.
After long a research I'm about to give up. Installed freetds, php5-sybase etc etc.
here is my connection file: (the default is set to sqlsrv)
....
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'myhostname:myport',
'database' => 'mydatabasename',
'username' => 'myusername',
'password' => 'mypassword'
),
....
and the error that I am getting is this one:
PDOException
SQLSTATE[01002] Adaptive Server connection failed (severity 9)
Any sugestions? If you guys need more details please ask :)
Thanks in advance
I solved my problem. It was missing #domain in my query string example:
$pdo = new PDO("dblib:host=xxxx:1433;dbname=yyyy", 'username#domain', 'password');
I get solution in Read from the server failed when trying to connect to sql-azure from tsql
Edit /etc/freetds/freetds.conf file and use 8.0 TDS version.
If haven't this file install FreeTDS with
sudo apt-get install freetds-bin
Check these:
port separator is "," on windows and ":" on linux/Mac. Since you have 1433, the default one, it is better probably not to use it at all
definitely test first from command line using one of these :
$ tsql -S sectionNameInFreetdsconf -U user -P pass
$ tsql -H hostname -p port -U user -P pass
locate freetds.conf on your disk. It is possible it exists in several places and tsql uses one while PHP used another one. Best is to symlink them into one common file and test on that. Note that a common place for that file is ~/.freetds.conf beside /etc/ or /usr/local/etc/
there should be a [global] section on your freetds.conf file. Put there these lines :
tds version = 8.0
text size = 20971520
client charset = UTF-8

Composer update ran via puppet times out

I'm using composer to manage dependencies. And basically want I want to do is automatically run composer update in puppet config when vagrant up is running.
I'm using puphpet to generate puppet files for vagrant.
I added composer::exec section in this code in the default.pp file:
if $php_values['composer'] == 1 {
class { 'composer':
target_dir => '/usr/local/bin',
composer_file => 'composer',
download_method => 'curl',
logoutput => true,
tmp_path => '/tmp',
php_package => "${php::params::module_prefix}cli",
curl_package => 'curl',
suhosin_enabled => false,
}
composer::exec { 'composer-update':
cmd => 'update',
cwd => '/var/www/myproject'
}
}
Some times I'm getting this error in output:
Error: Command exceeded timeout
Error: /Stage[main]//Composer::Exec[composer-update]/Exec[composer_update_composer-update]/returns: change from notrun to 0 failed: Command exceeded timeout
And there is no timeout property in puppet composer.
How to solve it?
Take a look at http://docs.puppetlabs.com/references/latest/type.html#exec-attribute-timeout - it is possible to set a timeout for an exec resource. If the puppet composer module does not provide an option to override that, it really should IMO. And if by a chance it is composer itself that's timing out, not puppet exec, you'd wanna try
export COMPOSER_PROCESS_TIMEOUT=600

Categories