Why is my Faker in my Laravel app not registering? - php

I'm trying to add Faker to my laravel site, however I seen to be running into an issue I can't quite put my finger on. I'm using docker with this also (side note). I am trying to make some seeds, but this is the error im getting. I was for sure that laravel had faker already installed within it. the issue is with line #25. When I don't put a \ in front of $faker = Faker\Factory::create();, I get faker error image #1. When I do put a \ in front of $faker = \Faker\Factory::create();, I get faker error image #2. Just trying to get this to work at the end of the day.
Note, I have not pre installed Faker at all. I was informed it came built into laravel.
Here is the entire error when you add the \ infront of Faker:
With the \ in front
and here is the entire code on that same page:
\Faker code

It was my line 31. I wasn't using the randomFloat() correctly so it was causing those errors.
The correct way to use it was:
'price' => $faker->randomFloat(2, 0, 1000)

Related

How to find exact error line in laravel 5.4 blade?

I know laravel caches blade files, and when there is an error in blade, in version 5.3 error would be something like this :
Undefined offset: 0 (View:b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php) line: 47
Then I can go to cached files and find the exact line,
But in version 5.4 laravel reference the exact blade file(not cached file) but without a line number! Something like this :
Undefined offset: 0 (View: C:\wamp64\www\project\resources\views\events\partial\event_details_members.blade.php)
in Collection.php (line 1537)
Now how to find the error?
UPDATE
I know where the problem is, and how to fix that, But I want Laravel to tell me this automatically whether I have to look for it manually. what if the blade file is very big?
As of Laravel 5.7, the output shows stack frames on the left side and details of selected frame on right side. If you cruise through the stack, you'll find that one of the entries in there is the parsed version of your blade file (normally located near the (main) frame towards the bottom of the stack). Clicking this frame will take you to the exact line of the blade file that resulted in that exception.
its not an easy way to find the error which raised in a cached view file.
but if your debug mode is off and you are going to find it out very quick,
I suggest this following steps:
I know this is not tidy.
1- find error in ./storage/laravel/log/today.log :
for example:
(b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php) (line : 47)
2- output the files content usng cat :
cat ./storage/framework/view/b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php
(file name from error log)
3- copy the content from terminal to an editor (from first line to the end)
4- you can find the buggy line.
You can use Laravel Debugbar. This is easy to use. Follow below link you will get what you want.
https://github.com/barryvdh/laravel-debugbar

Unable to create package in module builder or Deploy a new package in SuiteCRM

I am unable to create a new package from module builder. In module builder, when I enter a package name and key and hit save, it does nothing.
When I inspect in chrome, the console logs the following error:
Uncaught TypeError: Cannot read property 'value' of undefined
at validate_form (sugar_grp1.js:228)
at check_form (sugar_grp1.js:160)
at Object.handleSave (ModuleBuilder.js:905)
at HTMLInputElement.onclick (/XXXXXX/index.php?module=ModuleBuilder&action=index&type=mb#ajaxUILoc=&mbContent=module%3DModuleBuilder%26action%3Dpackage%26new%3D1:1)
Any suggestions on what I can look at or do to debug?
I'm using SuiteCRM 7.7.8
Php 7
I thought this might be a permissions issue, so i made sure all folders and files are 755 and tried to create the package again but got the same error.
I do not have any custom modules. this was the first one im trying to build.
I get similar errors if i try to export a module in studio also.
When I dig deeper, the exact line that fails in sugar_grp1.js is var current_module=document.getElementsByName("view_module")[0].value;
There is no element with name view_module on the page. It appears that this is happening to other users also. Please see: https://suitecrm.com/community/forum/suitecrm-7-0-discussion/12418-unable-to-create-package-in-module-builder#42665
UPDATE: I have done the usual repair and rebuild everything along with JS groupings and JS. Still the same.
An easy solution, see following steps:
Open /cache/include/javascript/sugar_grp1.js
Go to line 228 or find the next text:
var current_fields='';var current_module=document.getElementsByName("view_module")[0].value;$.ajax({type:"GET",url:"index.php?to_pdf=1&module=ModuleBuilder&action=getModuleFields&current_module="+current_module,async:false,success:function(result){current_fields=JSON.parse(result);},error:function(xhr,status,error){var err=eval("("+xhr.responseText+")");}});for(k=0;k<current_fields.length;k++){if(isError!=true){val=current_fields[k].toUpperCase();if((operator=="=="&&val==item1)||(operator=="!="&&val!=item1)){isError=true;add_error_style(formname,validate[formname][i][nameIndex],'Invalid Value: Field Name already exists');}}}
Remove this line.
QuickRepair.
Clear your Browser Cache and try again.

Array to string conversion - Project Crash [Laravel]

I am getting an error like this:
Array to string conversion
Inside:
/var/.../vendor/cartalyst/sentry/src/Cartalyst/Sentry/SentryServiceProvider.php
Code snippet where the error was thrown:
throw new \InvalidArgumentException("Invalid hasher [$hasher] chosen for Sentry.");
I was doing ordianry work in one of my controllers and this error occured when I clicked on one of the buttons inside my blade.
I have commented the code out but the error still is being displayed, not only on this one page but on every single one in my project. I can't even go to my /home/index.php page.
I have done
composer update
inside my project but that did not help. What can fix the problem?
#update
Yes I have checked sentry config file before I've made a new topic. I have the same problem when I load older versions (which do not contain the latest changes I've made today) of my project on to apache server which is running on Ubuntu 14.04.
Ideas what causes the problem?
In the config for Sentry you have to define a hasher.
It has to be a string. It can be 'native', 'bcrypt', 'sha256' or 'whirlpool'. Apparently in your app, it's not a string, but an array. Check your configuration. It's probably in app/config/packages/cartalyst/sentry/config.php

Error when trying to convert html to pdf using DomPDF

I'm using the Barryvdh/laravel-dompdf which is a laravel 5 wrapper for the domPDF library (Link to GIT). But after I ran a composer update on my project, I get a error message when I try to convert a html file to a pdf file. The error is as follow FatalErrorException in class.pdf.php line 1876: Call to undefined method Cpdf::o_rapport(). I couldn't find a solution for the specific problem so I tried to downgrade the version of the Barryvdh/laravel-dompdfand run composer again, but that didn't help. So after that I looked at the stacktrace and tried finding the piece of code that fires the FatalError, but nowhere in the code the method o_rapport() is being called, even if I use the search function of my IDE to search my complete project for this method, no reference are found so that is a dead end aswell.
Now I want to ask if someone did encounter the same problem as me and how to fix this.

Laravel 4 Commands stopped working suddenly

Back from vacation, and when I'm trying to run one of my previously working command:
php artisan list
Throws me:
[root#api2]# php artisan list
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function getArgument() on a non-object","file":"\/var\/www\/html\/api2.alariscms.com\/vendor\/laravel\/framework\/src\/Illuminate\/Console\/Command.php","line":153}}
And I seriously cannot understand why this happens. I tried debugging the file that throws an error. It awaits argument:
InputInterface $input but it gets NULL
I don't know what can go wrong on a framework level to stop receiving the required object.
Any ideas where to start debugging from? Or I can reload configurations / update laravel via cmd?
Thanks
This is what I would do:
php artisan dump
composer dump-autoload
check for current Laravel version
and then go to that specific command and check for bug there.
Also, what kind of argument are you trying to pass to command ? Is that object - if so check where is implementation of that class ?

Categories