-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error: primaryKey() #21
Comments
Thanks for submitting the issue. |
I'm experiencing a similar issue but mine stems from the Application.php file. Everything was working perfect until about the 4:25:00 point in the lesson. I used var_dump at the bottom of Application constructor to target the specific bug, and for me it is occurring in this line: $primaryKey = $this->userClass::primaryKey(); Fatal error: Uncaught Error: Non-static method app\models\User::primaryKey() cannot be called statically in D:\xampp\htdocs\I211_Project\core\Application.php:45 Stack trace: #0 D:\xampp\htdocs\I211_Project\public\index.php(24): app\core\Application->__construct('D:\xampp\htdocs...', Array) #1 {main} thrown in D:\xampp\htdocs\I211_Project\core\Application.php on line 45 var_dump indicates it is returning the id, and the PHP cookie does exist. |
All these problems with static calls are due to the php version. It has to be higher than 7.4. |
I am using version 8.1
pon., 4 kwi 2022 o 06:56 RobertoVasquez01 ***@***.***>
napisał(a):
… All these problems with static calls are due to the php version. It has to
be higher than 7.4.
You can temporarily modify the function so that it is not static, but
later in the lesson you will experience a similar problem. That's why it's
better to *update the php version*
—
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG7LDYVQUKWUMGYJDNPBEVDVDJZALANCNFSM5R2XYSNA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I also applied PHP settings to 8.0.1, and to be sure ran 'php -v' in the terminal with the following result: PS D:\xampp\htdocs\I211_Project> php -v I still get the same fatal error Non-static method app\models\User::primaryKey() cannot be called statically |
Yes, I was wrong in the first part of my comment. It was because I'm using php version 7.3 and throughout the video tutorial I had to make a few small changes to take advantage of this great input from @thecodeholic, and I was quick to say that the error is based on the php version. |
Thank you for the information! Will give this a shot and provide feedback on whether or not it was successful. |
I eventually started over and rebuilt the app from the beginning and got it to work. |
Perfect! |
Howdy, love this mvc-framework! Been trying to fix error around the end of Login section. I still keep getting error for "findOne". |
Declare the findOne function as static in the DbModel class. |
Fatal error: Uncaught Error: Non-static method thecodeholic\phpmvc\db\DbModel::primaryKey() cannot be called statically in C:\wamp64\www\link\vendor\thecodeholic\php-mvc-core\Application.php on line 54
The text was updated successfully, but these errors were encountered: