Skip to content
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

syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE) #1

Open
sanbroz opened this issue Sep 11, 2022 · 3 comments

Comments

@sanbroz
Copy link

sanbroz commented Sep 11, 2022

http localhost/products

HTTP/1.1 500 Internal Server Error
Connection: close
Content-Length: 157
Content-Type: application/json; charset=UTF-8
Date: Sun, 11 Sep 2022 06:20:47 GMT
Server: Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/7.4.29
X-Powered-By: PHP/7.4.29

{
"code": 0,
"file": "C:\xampp\htdocs\src\Database.php",
"line": 5,
"message": "syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE)"
}

@daveh
Copy link
Owner

daveh commented Sep 12, 2022

This looks like a PHP version issue - if you're on a version prior to PHP8, you can't use constructor property promotion (adding visibility modifiers in the constructor arguments)

@corelus
Copy link

corelus commented Nov 1, 2022

Hi @daveh, great tutorial & nice work! thanks for sharing!
But could you please provide the environment requirements such as which PDO drivers are needed to get the project works. I started with this tutorial on youtube & wanted to continue the full course with Authentication & so on on Udemy, but I am kind of stuck at this point, because contrary to you in your the main tuto I'm not using MAMP, I am using docker and I'm running PHP 8 with MariaDB 10.9.3 & I've PDO Sqlite with its library SQLite Library | 3.34.1 running & I got the message -> could not find driver","file":"/var/www/html/src/Database.php","line":16

@daveh
Copy link
Owner

daveh commented Nov 1, 2022

@corelus I'm actually using XAMPP, but the results should be the same. To use PDO with MariaDB you need to install the PHP MySQL package - on Linux this would be

sudo apt-get install php-mysql

for example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants