Laravel - database and linking

I have installed laravel onto my account. I already have a database for the php website I was previously creating and now want to use this database in my new laravel application. I think I need to configure this in the env file but dont know what needs to be changed in the env file. Also how does migration and seeding work on a hosted site (all the tutorials only show how to do this from the command line)

I have made a partial view for a navigation and don’t know how to link to pages the double brackets don’t work and the way I have linked directly to this page in the nav means the view isn’t displaying correctly http://lindacom.infinityfreeapp.com/laravel/resources/views/user/signin.blade.php

@Admin said :

You can use Laravel with some effort, but it doesn’t work very nicely.

Laravel by default assumes that the webroot of your website can be changed to the public directory, and the other folders are not web accessible. You could edit the index.php file and move everything from the public, or add some good .htaccess rules to the main folder.

Another issue is that many administrative functions of Laravel require the Artisan command line tool, which you can’t use on the free hosting server.

Honestly, Laravel was not designed with a regular web hosting service in mind. It can work, but it won’t work well.
1 Like

Thanks for your reply. I have been able to sort out the issue with linking to pages however I still can’t see how the mySQL database for my account can be accessed from the laravel framework which I have downloaded to my account. Do I need to write a script in a file

I just checked your site and i just saw laravel codes are shown (which should not to do) idk if it’s normal ;-;

do you want to write config file for laravel connection?

yes, I would like to know how to connect to the database please.

I followed a tutorial and have put the database details in the .env file. The tutorial mentions migration and seeding from the commandline.

There is already a migrate folder in the file structure and a seeding folder also which automatically created files when I downloaded Laravel so I know I dont have to do anything there but I dont know how to connect to the database when I am not using the commandline.

What is your Laravel version, so that I can help you?

Version : 5.8.16

Read the Laravel’s official documentation about the database configuration about that.

1 Like

Thank you very much! I think it’s this part of the documentation that I need now - Running A Select Query - To run a basic query, you may use the select method on the DB facade

I think I have done the database settings part but to run a query I dont know whether to put this code in a seperate file or the main app > http > controllers > controller.php file

1 Like

You need to put that code on a separate file, instead of overwriting the contents of the App\Http\Controllers\Controller class file.

Thank you for your help.

1 Like