I am new to PHP and Laravel.
I installed Laravel and Composer , created new project and it is working fine.
Now when i tried to migrate a database using this command php artisan migrate i got errors, i wonder is it something related to not installing Xampp ? i am running Mac OS
The errors i got is
1 PDOException::("SQLSTATE[HY000] [2002] Connection refused")
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=app", "root", "", [])
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
Xampp has nothing to do with Laravel itself. Xampp is a set of tools that is usually used together to deliver websites. Xampp just makes it easier (supposedly) to install those set for you. Rather than having to install and setup all yourself.
Today people tend to avoid such sets in favour for tools like Vagrant or Docker.
Laravel even provides its own Vagrant setup called Homestead.
See ie. in Laravel 5.5 docs: https://laravel.com/docs/5.5/homestead
If you don't want to use Homestead but build your own server environment there's also tools to make this easier for you.
For example there is http://www.puphpet.com for PHP + Vagrant and https://phpdocker.io/ for PHP + Docker.
Xampp is not required but a php server like apache or nginx is required also in order to use mysql you should have mysql installed you get this error
PDOException::("SQLSTATE[HY000] [2002] Connection refused")
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
because the mysql service is turned off so I think you open Xampp control Panel and you start mysql in order for it to work and this is why you have asked if Xampp is required am I right !!!
Actually to prove that Xampp has nothing to do with Laravel you can start the mysql server from command line I will give you example in windows OS.
if you have xampp installed on C:/ Driver lets say then try cd(change directory) into this path in your command line
cd c:/xampp/mysql/bin
start mysqld.exe // this will start the mysql service for you
now you can navigate to your Laravel app and try to migrate this time you won't get connection refused error and that is because you have started the Mysql server from command line.
I think this proves that Xampp has nothing to do with Laravel.
Hope this was helpful, good luck.
Mac OS comes with PHP built into it. You should be able to use php -v to see what version. Use php -S localhost:xxxx to output the local directory to a local address.
For example, to run laravel locally, open the terminal cmd+spacebar, type terminal, open it, then use change to the path where your laravel project is.
Type php -S localhost:3000 and it should give you a confirmation in the terminal. Now open a browser and go to localhost:3000 and it should show your project.
Related
I'm new to Mac Environment. My colleague recently gave me a Laravel project that I had to work on with a new cosmetic changes.
Like usual I get all the files and do the typical things like git the project, install composer, install npm, database setup, .env file setup and run the project.
I can open the project on the landing page. But what happened was, when I tried to sign in, I failed to enter the homepage. When I check the console it says: View error Message
POST http://localhost/aplikasi-laravel/MY/user/login 500 (Internal Server Error) Jquery-3.1.1.min.js: 4
Request URL: http://localhost/aplikasi-laravel/MY/user/login
Request Method: POST
Status Code: 500 Internal Server Error
Remote Address: [::1]:80
Referrer Policy: no-referrer-when-downgrade
For your information, if I install and create a new Laravel project on this OS, it works. But I need to work on this project. So I have no choice.
My Project Specifications are as below.
Laravel: Laravel Framework 5.4.36
PHP: 7.1.28
MySQL: 5.7.26
So what I'm doing is I install MAMP, downgrade to PHP 7.1.31 (only this php version is available), try running the project. Still failed. So I uninstalled it.
I tried using homebrew and XAMPP, and still failed.
My OS is Mac OS Catalina.
Because I wasting so may time setting up the environment on the mac, I'm try to use my PC with Windows 10 installed. So here's my setup.
Platform: XAMPP
PHP: 7.1.28
With the same code and setup, I was able to run smoothly without any errors on Windows 10. So I think it shouldn't be a code problem (maybe).
Since I need to work with the Mac OS environment, I want someone to help me to give an idea on how to solve this problem. Thanks.
Windows 8.1 - mySql 5.6 This is a strange one: I went into command prompt entered: mysql -uroot as usual and got back: 'mysql' is not recognized as an internal or external command, operable program or batch file.
I went looking for mysql.exe and it is just gone, not in trash or any where else... just gone. The service mysql56 is running and I can access the database with adminer and PHP.
My question is: can I extract another zip and copy the mysql.exe to C:\Program Files (x86)\MySQL (I think that's where is should be) to get back the command prompt access?
The only thing that has really changed is that I downloaded adminer management tool and adminer editor to use since the new versions of phpmyadmin have tanked and cannot run past a timeout error. I don't see how or why adminer would have snarfed the mysql executable anyway.
Thanks for any help ... did search here and else where but found nothing resolve my question.
Thanks for the link to the post Mike. It provided a good hint. What appears to have happened -something had it's way with my environment path and windows weak search could not find C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe. I'll spiff up my environment variable and should be good to go. Thanks again.
I was using Netbeans IDE 8.0.2 on Windows 8.1 to develop my PHP applications. There was no issue with it. But later on when I start using Netbeans (same version) on windows 7, Although the ftp connection was successful but it was giving error:
Error while listing files /.
After too many searches I found that by disabling features at firewall the problem is solved, All you have to do is just run a simple command in cmd.
Run cmd in administrative mode
Paste following command
netsh advfirewall set global StatefulFTP disable
Now you are almost done!
Goto Netbeans->New Project->PHP->PHP Application from remote server
Follow other instructions and you are done! (Note sometimes you will need to do that with passive mode)
I want to run my first php project in eclipse(with help of pet package). When I run my project (index.php) eclipse show an error with below message :
Page Login failed with error. Could not connect to the server.
More information :
When I enter "http ://localhost" in my browser it couldn't find server
I'm using kepler version of eclipse
I'm run eclipse in MAC OSX
I think my local server didn't start or I haven't local server. How can I solve this error? How can run local php server in mac ?
Best Regards
You need to install a server package, something like MAMP. Then you need to configure it in order to be driven by Eclipse, using Xdebug, which is a module for Apache. In order to set up your configuration with Xdebug, take a look here: http://wiki.eclipse.org/Debugging_using_XDebug
I have a iis development server set up and i have just successfully downloaded and installed symfony2 which is placed in the web root of this server and im trying to create a bundle within my project and i seem to be getting this error message in the dos box:
the program cant start because of php5.dll is misisng from your computer. Try reinstalling the program to fix this problem
even though the dll is in the directory of the php folder on the C: drive on my computer.
and yes i entered php app/console generate:bundle into the cmd box.
Any suggestions would be very much appreciated
It seems the PHP was not installed successfully or IIS was not configured correctly for the available PHP.
I would recommend to unistall the previous PHP on IIS and install Microsoft Web Platform Installer first; then search for PHP 5.4> and PHP Manager for IIS in the productions list and add/install them.
This is much safe and reliable than installing php manually, specially that it will do IIS configuration for PHP automatically