How do I set up MySql workbench to be used with laravel? - laravel

I'm really new to using Ubuntu. During university we used MySql Workbench as our way of interacting with the databases we would seed in Laravel and I'm looking recreate this on my own PC. How do I go about installing and configuring workbench to be used with my Laravel projects? I had it (workbench) installed but it doesn't seem to 'connect' to Laravel. Apologies if that doesn't really make sense but I'm new to a lot of this and it's a little intimidating.
Do i need to install SQL on it's own then configure workbench to work with it? Thanks for any help

For installation of MySQL it should be as simple as sudo apt-get upgrade, sudo apt-get install mysql-server.
To use the DB in your laravel project you just need to specify it's settings in your .env file (DB_HOST would be 127.0.0.1 if your DB is local, and then DB_USERNAME and DB_PASSWORD).

Install MySQL Workbench on Ubuntu:
sudo apt-get update
sudo apt-get install mysql-workbench
Update your env settings and see below how to set connection in workbench:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=DBNAME
DB_USERNAME=root
DB_PASSWORD=secret

Related

How to enable php-Mcrypt extension in Laravel Homestead

I am trying to get an old Laravel 4.1.x app up and running again so that it can be modernized. This requires an environment with PHP 5.6 and the Mcrypt extension. I have installed Homestead 9.0.3 (the latest stable version). Within the VM, I have set the PHP version to 5.6
sudo update-alternatives --config php
I have then installed the php-mcrypt extension
sudo apt-get install php5.6-mcrypt
I am now able to create a new Laravel 4.1.x project, which is a process that requires Mcrypt to complete, so we're certainly getting somewhere:
composer create-project laravel/laravel="4.1.*" myAppName
However, when I browse to the webpage for myAppName, I see the message:
Mcrypt PHP extension required.
I have also tried steps that are usually recommended for this problem, ie:
sudo ln -s /etc/php/5.6/conf.d/mcrypt.ini /etc/php/5.6/mods-available/mcrypt.ini
sudo phpenmod mcrypt
sudo service php5.6-fpm restart
But I still get the same message in the browser.
What step have I missed?
With homestead v9 you should be up and running with php5.6 out of the box as stated in
here, but unfortunately it is not your case, and I understand that...
Old packages were not installed by default (php5.6-mcrypt), as you mentioned and they should be added by hand via:
sudo apt-get install php5.6-mcrypt
After that all packages are ready, up and working, especially php5.6-mcrypt.
The root of your problem is in multiple site definitions under your homestead.yaml.
Most probably some of them are overlapping and your nginx is referring to the wrong resource/site_definition, and wrong paths.
Therefore you might think some strange php versions or routes are run/executed.
You can verify that, by deleting some/all of them, leaving the only one important for you - in (/etc/nginx/sites-enabled/...).
Of course please do that inside the container and issue sudo service nginx restart, afterwards...
All of your problems should be gone after that.
If something goes wrong. You could easily recover your current installation to current state using vagrant destroy and vagrant up afterwards, cause all is saved in Homestead.yaml.
In my installation Homestead v9 is running with php5.6 on laravel 4.1 without any problems...
Hope it helps #jsm...
Because all the PHP versions installed on homestead you need to set the PHP version for a site in the Homestead.yaml.
First check what version the server is running with phpinfo();
Check the file /etc/nginx/sites-enabled/homestead.test and look for this line:
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
If you didn't set the php version on the sites list, this file will be pointing to the php7.3.sock.
In this case the version 5.6 has mcrypt installed, but 7.3 don't.
You can just replace the line
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
for
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
and then reload nginx with sudo nginx -s reload.
Or set the php version on Homestead.yaml:
sites:
- map: homestead.test
to: /home/vagrant/code/public
php: "5.6"
And then run vagrant provision, it will change the nginx configuration for PHP 5.6.

hInterface 'Throwable' not found

when querying the database with sql error laravel throws Throwable interface not found instead of the query exception.
i have a same trouble yestoday with 'laravel new demo', meybe the repository server has error before. i rebuild my laravel project with 'composer create-project laravel/laravel=5.4 demo --prefer-dist' this afternoon, it work! do like this.
In my last project, I got this error too. I used php 5.6.30 version. When i upgrade to 7.0.1 version, everything is fine. http://php.net/manual/en/class.throwable.php
I was using php5.6 and got this after I did composer update.
So I installed the php7.1 following this answer
Then I disabled php5.6 using
sudo a2dismod php5.6
and then I ran the following to enable 7.1
sudo a2enmod php7.1
and finally restarted apache2 using.
sudo service apache2 restart
and it worked.
I fixed mine when I did a netstat -tln and found out the mysql is running 0:0:0:0:3306, and on my .env file is set to DB_HOST= 127.0.0.1. I changed it to DB_HOST=localhost and is working fine right now.

Is Laravel/Homestead can be used on other PHP frameworks?

I am not yet used Laravel and I am just curios if the Homestead can be used on other PHP frameworks like CodeIgniter?
Homestead runs on Ubuntu within a Virtual Machine. It comes with the following software installed:
Ubuntu 14.04
Git
PHP 7.0
HHVM
Nginx
MySQL
Sqlite3
Postgres
Composer
Node (With PM2, Bower, Grunt, and Gulp)
Redis
Memcached
Beanstalkd
Pretty much anything a webserver needs to run any kind of PHP framework. If there's something missing for the framework you're using, you can install it.
You can of course use it for any php related project. But be careful when configuring the Homestead.yaml file to correctly set the path to your projects.
sites:
- map: laravel.app
to: /home/vagrant/Code/laravel/public
- map: codeigniter.api
to: /home/vagrant/Code/codeigniter
You can also setup multiple databases if you need to.
Simply don't forget to run bash init.sh and vagrant provision each time you modify the config file.

Laravel Migration Error :: PDOException, Could not find driver

I am trying to make a laravel and stucked when migration. when i enter php artisan migrate in terminal, showing PDOException error. attaching my screenshot of terminal and phpinfo.
What i sthis issue, How can i solve this,
I am using Xampp.
Anybody please help me.
Thanks
Try re-installing Xampp? You could use Laravel homestead for a virtual machine, it makes sure you have the proper PHP version and the required dependencies needed to install and avoids having to run Xampp or MAMP or WAMP or any of the amps.
It looks like Xampp cannot find: /usr/lib/php5/20121212/php_pdo_mysql.dll, so make sure that file exists.
You may need to re-install PHP PDO on your machine, refer to: http://php.net/manual/en/pdo.installation.php
Also per PHP docs:
PDO and all the major drivers ship with PHP as shared extensions, and
simply need to be activated by editing the php.ini file:
extension=php_pdo.dll
Please check you have installed more than one php version in your system, one is running for web server and another for php CLI, using PHP_INFO for web and php --ini in commandline, if different version found then upgrade or downgrade means make it one version configuration, and make sure PDO is enable in your system.
From php5.6 to php7.0:
Apache:
sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart
CLI:
sudo update-alternatives --set php /usr/bin/php7.0
From php7.0 to php5.6:
Apache:
sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart
CLI:
sudo update-alternatives --set php /usr/bin/php5.6

Laravel installed but confusion remains

I have ubuntu 14.04 and LAMPP is installed. I was learning Laravel 4, but get a lot of confusion on it's documentation, below I list few of issue.
How to install laravel?
what I did :
copy github repository into /opt/lampp/htdocs/larva and run composer install, Laravel is installed and I can access it with http://localhost/larva
What is homestead? is that another way to install laravel or this is additional thing?
What is artisan? if I use artisan then do we need to use homestead also?
what I did ( in terminal )
cd /opt/lampp/htdocs/larva
php artisan serve
it started the service and I can access laravel with htpp://localhost:8000 BUT if i close this terminal then URL is lost
and there is one other way is using vagrant? do we need to use vagrant if we installed it already?
one more thing is Nginx?
overall these vagrant, Nginx, Homestead, artisan,and composer methods create such a mess.
Please clear the clouds and please do not mention what is vagrant Nginx and all. I just want to know that do I need to do something with Homestead and vagrant if i have installed using git repository and composer way?
Thanks
Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine.
Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.
When you close the terminal, you are stopping the service on port 8000. You always can create a virtual host, and point its root to your larval installation /public directory
you dont have to use vagrant to run laravel. Vagrant is just your 'bridge' to Virtual Mashine.
If you installed LAravel via composer and you got it work on localhost:8000 then you dont need neither homestead or vagrant

Resources