Support the ongoing development of Laravel.io →
Installation Configuration Database
Last updated 1 year ago.
0

Are you calling app/views/test.php directly? Or are you using index.php with a route/controller? Can you show your code to render the view?

Last updated 1 year ago.
0

barryvdh said:

Are you calling app/views/test.php directly? Or are you using index.php with a route/controller? Can you show your code to render the view? Hi barryvdh,

  1. yes , i'm calling the page directly on localhost/myLaravel/app/views/test.php.
  2. no, i did not use a route/controller. but i use your idee to create a new testDbController.php under folder app/controllers , however i does'n help for me.
<?php class testDbController extends BaseController { public function testDB() { return View::make('test'); } } I don't change anything after installed. Just database.php under app/config. Should i use composer do anything more? Anyway, thanks for your suggest.
Last updated 1 year ago.
0

You need to use a route and/or controller so that Laravel is booted and all the necessary resources are loaded, simply accessing the view.php will only run that script and won't load any of the Laravel system, hence DB class not being found.

You should set /public to your document root so that all requests are rewritten to the index.php and so are processed by Laravel.


Create a route in your routes.php

Route::get('/testdb', ['uses' => 'TestDbController@testDB');

Then load http://localhost/testdb (after you've set /public as your document root)

Last updated 1 year ago.
0

Hi, i have solved it, thanks again @iWader , i should create a Model for testDB, and refresh it with command:

php artisan dump-autoload

so that laravel know such a thing. And i should configurate 2 place of database.php. One is in app/config/database.php, the other is in app/config/local/database.php.....i don't konw why in this folder exist again a database.php. But i configurate it and finally success to connect to database. And this tutorial give me also a lot of help, see: http://www.amazingcode.de/laravel-4-1-erstellen-einer-blog-app...

Last updated 1 year ago.
0

I suggest reading the docs (http://laravel.com/docs/4.2) and following some beginner tutorials, perhaps on https://laracasts.com

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.