skip to Main Content

I’m trying to learn Laravel, but ran into an issue I hope you can help resolve. Recently, while working to learn php programming I installed XAMPP, without problem and used it with both php and MYSql. It uses the localhost IP of http://127.0.0.1. In the new course I’m using to learn Laravel after the installation of Laravel the setup uses http://127.0.0.1:8000/, which I can access using Visual Code Terminal and entering "php artisan serve". Following the course instructions for setting up Visual Code I next installed an Extension titled "Connect to Server". After installation of the extension I get a dialog box to connect to the database and it defaults to the 127.0.0.1:8000/ address. If I click on the connect button I get an error. That said, if I start XAMPP and change the value in the dialog box and use the XAMPP 127.0.0.1 address I make a successful connection to MYSQL.The question I have is this, am I going to have a problem in the near future as the result of the two different 127.0.0… addresses and if so is there any way to resolve it?

If you look at the problem I have outlined the issue and hope I can get some resolution before I get to the point I run into trouble.

2

Answers


  1. You can use php artisan serve if you wish to use the laravel’s serve command. If you wish to use xampp/wamp, you can add a virtual host in your httpd-vhosts.conf file.

    In case of wamp, httpd-vhosts.conf file is in C:wamp64binapacheapache2.4.51confextra where 2.4.51 is the apache version if you did not change the installation path.

    In case of xampp, it is C:xamppapacheconfextra

    As for the vhost setup, add the snippet below (change depending on your project path):

    <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot "path-to-projectpublic"
        ServerName project.local
        <Directory "path-to-project">
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
    
        ErrorLog "logs/project-errors.log"
        CustomLog "logs/project-access.log" common
    </VirtualHost>
    

    Next is open your notepad as administrator then go to C:WindowsSystem32driversetc then open hosts file. add 127.0.0.1 project.local

    restart wamp/xampp. You should be able to access your project using project.local

    Login or Signup to reply.
  2. Xampp comes with Apcahe/ Mysql so when you run xampp it runs apache and mysql both.
    but php artisan serve starts only a php server so your database related thins will not work if you are not running mysql separately (With xampp or as a standalone installation)

    You can find more about what the artisan serve command to here PHP artisan serve code

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search