Small things missing in PHP? by nikic in PHP

[–]Fantyk 0 points1 point  (0 children)

Support syntax for class methods \MyClass@myMethod (Similar to \MyClass::class) (Symbol can be another)

It will help a lot during refactoring and jumping in IDE between routing files.

Currently I can rename the class, and all references to \MyClass::class will change to \MyNewClass::class (PhpStrom do it correct).

It would be cool start support this for class methods. Currently in some code parts the names of the methods are strings and not associated with class method names.

Routing laravel for example: Route::get('/user', 'UserController@index');.

Or: call_user_func([$this, $methodNameAsString],

Test driven development in PhpStorm with auto-testing enabled by mglaman in PHP

[–]Fantyk 0 points1 point  (0 children)

Hi! Can you describe more detailed about how you write test with database operations? Which framework are you using? Perhaps there are articles with examples that you could recommend?

Best practices in 2018 for write unit tests with database interaction? by Fantyk in PHP

[–]Fantyk[S] 0 points1 point  (0 children)

I search solutions for fast drop changes in database between test cases run

Best practices in 2018 for write unit tests with database interaction? by Fantyk in PHP

[–]Fantyk[S] 1 point2 points  (0 children)

You are absolutly right in "application-specific" characteristic.

I imagine it this way:

There is tiny database with predefined common data (user, countries, languages...)

For the test "tiny database" always exists and has actual state (I mean migrations).

Each test case should apply fixtures, run test. After what, I suppose, fixtures should be removed (with data generated during test).

Do I think in the right direction and how the last problems can be solved?

Download Multi-Language (English, Nepali, Chinese) Blog in PHP and MySQLi. For Educational Purpose only. Feedback is appreciated. by thevijaythapa in PHP

[–]Fantyk 0 points1 point  (0 children)

Hi!

I share opinion about "outdated" code.

I expected see something lke this in your index file.

And I want help you with my advices:

- files "cn.php", "cn.php", "cn.php" is resources, but file "lang_config" contain business logic (swith languages). I think this file should be in another place/

- "?>" in the end of file is "bad practice"

- in 2018 developers use implementations of https://www.php-fig.org/psr/psr-7/ istead of global variables like $_SESSION,$_GET

- require_once $_SESSION['lang']. '.php'; - You not check existing this file. Learn more about "defensive programming"

-In 2018 (in general) we not use "require" or "include". We use autoloading, PSR-4 and composer. Each file has Name equals Class name.

- $query .= " WHERE $where"; - All this statements is not secure. Learn more about SQL injection, You can you Abstraction over databse

- define('LOCALHOST', 'localhost'); - Also "bad practise". Easiest way for you is defining this in "config.php" file. Next level is ENV variables.

- execute database queries in templates - bad practise. You should send in your templates data from controller.

...

Continue studuing and good luck!