enter image description here Create a table in Laravel, when trying to migrate, this error occurs to me, someone can help me
Error trying to migrate with Laravel
try put in your app/Providers/AppServiceProvider.php
public function boot()
{
\Schema::defaultStringLength(191);
}
Related
That's not a breaking-mind thing but it's really annoying:
public function render(){
return view('home')->extends('layout.app')->section('content');
}
The error is
Undefined method 'extends'.
That's not even the only "fake error" i get but it's the only one in this project.
Does anyone know how to fix that?
I came across with interesting problem,
I am using lumen on my windows localhost, the problem is while I write incorrect code or syntax error in my view/blade, lumen shows blank page instead of error. However, in controller or another page I am able to debug my code, It shows error.
Error debugging is open in php.ini.
APP_DEBUG=true in my project.
I have tried to fresh install, still same.
Edit app/Exceptions/Handler.php file , method render
e.g. make something like this:
public function render($request, Throwable $exception)
{
if (env('APP_DEBUG')) {
dd($exception);
}
return parent::render($request, $exception);
}
or you can grab it as it is instanceof Illuminate\View\ViewException
I'm getting a weird error trying to use PHP Artisan. I don't know the cause, or even which file is causing it.
Just a few moments ago I ran php artisan migrate:reset to wipeout all the tables in my db. Worked fine.
Then I made a change to a file completely unrelated to the "stages" table, and when I try to run php artisan migrate it throws an error saying:
SQLSTATE[42S02]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'stages'. (SQL: select * from [stages] where [stages].[deleted_at] is null order by [opord] asc)
It throws that error no matter what I try to do, even just typing php artisan causes that fatal error.
Also, if I manually add a table called "stages" to the DB, artisan doesn't fail immediately, it tries to migrate the tables, then fails when it gets to the stages table, and it says it failed because "stages" already exists.
I don't even understand why artisan is trying to perform a select statement when I'm just trying to migrate my tables; and I especially don't understand why it's happening when running the php artisan command alone.
EDIT:
I traced the problem to some code that I had added to app\Providers\AppServiceProvider
public function boot(){
View::share('nav_stages', Stage::opord()->get());
}
I found a SO question about how to check if a table exists and I'm currently trying to make this work:
public function boot(){
if (Schema::hasTable('stages'))
{
View::share('nav_stages', Stage::opord()->get());
}else{
View::share('nav_stages', null);
}
}
The problem was caused by a bit of code I had in AppServiceProvider.php In the code I was trying to query the DB for data required by the navigation menu used on the entire site (a master page, layout, partial view, etc).
I replaced
public function boot(){
View::share('nav_stages', Stage::opord()->get());
}
With
public function boot(){
if (Schema::hasTable('stages'))
{
View::share('nav_stages', Stage::opord()->get());
}else{
View::share('nav_stages', null);
}
}
And added
use Illuminate\Support\Facades\Schema;
at the top of the file
I'm following along with this set of tutorials on laravel (They're excellent), and I keep running into this error:
PHP error: Use of undefined constant Article
whenever I enter this line of code:
$article = new App/Article;
I've followed everything to the letter, and used the command:
$ php artisan make:model Article
Model created successfully.
Created Migration: 2015_04_11_152306_create_ar
What I find unusual is that in the tutorial, no migration was created when this command was called. Anyways, I'm trying to enter some data into my sqlite database through tinker, but I'm unable to create an Article object, and therefore cannot insert into the database. How would I got about either solving or bypassing this issue?
You should use backslash \:
$article = new App\Article;
In laravel 4 when you try to render a view that does not exists in app\views or a view with undefined variables laravel will throw an exception or show error that helps with debug.
I have a fresh installation of laravel 5.0.13 and am having a tough time troubleshooting a blade template that shows a blank page when i render a view that does not exists instead or a template with undefined variables instead of throwing an exception or error which will clue me in when debug.
I have installed filp/whoops:~1.0. but still recieve a blank page
class ProfileController extends Controller
{
public function index()
{
return view('indexx'); //this view does not really exist
}
}
The file indexx does not exist in my resources/views and i expect Laravel to throw an exception but am getting a blank page instead, why?
Also when i render a view that exists with some undefined variables i simply get a blank page
Example:
class ProfileController extends Controller
{
public function index()
{
return view('index'); //this view exists
}
}
The content of resources/views/index
{!! $this_variable_was_not_passed_an_I_expect_error !!}
As you can see in the view file above the variable does not exist by laravel will simply show a blank page instead of throwing an exception or some debug error.
Also to note i change my laravel default view in config/views
'paths' => [
//realpath(base_path('resources/views'))
realpath(base_path('resources/themes/default'))
],
And laravel was able to render views from resources/themes/default as long as there is no error in the template however, if any error was encountered such ar undefined variable a laravel displays a blank page instead of showing error message
Also to mention that I install virtual box and vagrant on window 7
Could this be a bug or something? Please assist.
Try to change permission on the storage folder:
chmod -R 0777 storage
It worked for me.
I don't really know why this happened but its now working as required after i run
vagrant destroy to destroy homestead VM
and then vagrant up - to create the VM
The error messages has now showing up instead of blank page:
An alternative solution which helped me, is running
composer install
I deployed with git which auto ignores some files. running composer install fixed it for me.
I got the same problem but here comes the reason and the solution:
The logfiles in storage/logs needs to be owned/writable by the webserver user. Otherwise L5 gives you a blank page.
I run "php artisan ..." always as root. If an exception was thrown and Laravel creates a new logfile, then it's owned by root. On my Debian i run in the project root folder:
chown www-data.root * -R
to solve this problem.
//lavarel 4
* Add this to app/start/gobal.php
App::error(function(Exception $e, $code) {
$runner = new \Whoops\Run;
$inspect = new \Whoops\Exception\Inspector($e);
$handler = new \Whoops\Handler\PrettyPageHandler;
$handler->setRun($run);
$handler->setInspector($insp);
$handler->setException($e);
return $handler->handle($e);
});
//lavarel 5
* Add this to app/Exceptions/Handler.php
public function render($request, Exception $exception)
{
..........
$runner = new \Whoops\Run;
$inspect = new \Whoops\Exception\Inspector($e);
$handler = new \Whoops\Handler\PrettyPageHandler;
$handler->setRun($run);
$handler->setInspector($insp);
$handler->setException($e);
$handler->handle($e);
......
return parent::render($request, $e);
}