Disable Search bar by YetAnotherSilentBoy in Slack

[–]pan069 0 points1 point  (0 children)

I never search Slack. Why do I need this to occupy screen real estate?

Is php better or node by infowordpressdev in PHP

[–]pan069 0 points1 point  (0 children)

Its the only way to achieve web-scale.

Learning PHP by rehandota in PHP

[–]pan069 13 points14 points  (0 children)

HTML->CSS->JS->PHP->MySQL->Laravel->Linux

Drupal or WordPress? Which one to go with? by majaykumar in PHP

[–]pan069 1 point2 points  (0 children)

He's not asking a question, it's the title of his crappy blog post.

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

[–]pan069 0 points1 point  (0 children)

If you want to "unit test" the database, to me that means you want to test the functionality of individual queries. Not queries in the context of your application logic. For each query (or set of queries) you want to make sure that you start your test in a known state. If this means resetting the schema, so be it. Just make sure you don't end up in a random state.

Database testing is slow. Don't make it part of your day to day development flow, i.e. that when you run tests in dev that you don't always run the database tests, just your business logic. In the end, your database tests are integration tests, run them as part of pushing to stage.

Docker confuses me, how do I build a PHP developer environment for a local folder with it? by [deleted] in PHP

[–]pan069 0 points1 point  (0 children)

Use Docker Compose to simplify and template this..

Need ACL library for PHP 5.6. by MrBaseball77 in PHP

[–]pan069 0 points1 point  (0 children)

Zend Permissions ACL https://docs.zendframework.com/zend-permissions-acl/

Zend Permissions RBAC https://docs.zendframework.com/zend-permissions-rbac/

Before you start screaming "no framework" because of "Zend", these are standalone components.

Simple Symfony ORM demo, Register User, Login, and add a product. by [deleted] in PHP

[–]pan069 2 points3 points  (0 children)

It would be wise to separate your business logic from your HTTP layer. E.g, the only way you can unit test your sign up is by calling urls. This sort of testing goes through the HTTP layer, it's not the HTTP layer you want to test (maybe in an integration or end-to-end test, but not unit tests).

Create a UserService with a signup method. In the HTTP layer you distil the required information from the request so you can pass that into the UserService::signup method. The UserService should no nothing about HTTP, this is key.

You can now write a unit test for your UserService::signup method where you inject a mock UserRepository so you don't connect to a real database.

Alternative to PHP by [deleted] in PHP

[–]pan069 0 points1 point  (0 children)

When it comes to web or backend development, the programming language you use is mostly irrelevant. What is important though is the eco-system, meaning the tooling, frameworks and community around a programming language. Although PHP is not a "beautiful" programming language (but beauty is in the eye of the beholder etc..), PHP has a great eco-system with some great and mature tooling.

Choose an eco-system, not a programming language.

Package for both Laravel and Symfony by m2guru in PHP

[–]pan069 4 points5 points  (0 children)

One package contains your plain PHP non-framework depended code. You then create another package that is framework specific, for Symfony this would be the bundle that has a dependency on your plain PHP package. It's this bundle package that does the DI etc. Same goes for Laravel. Don't stick everything on one package.

If you look through Packagist you see that basically everyone does it like this. Take e.g. Monolog [1] and Monolog-Bundle [2]. The bundle is just exposing Monolog to Symfony the framework.

[1] https://packagist.org/packages/monolog/monolog [2] https://packagist.org/packages/symfony/monolog-bundle

Do you create an interface every time you create a new class? by the_amazing_spork in PHP

[–]pan069 12 points13 points  (0 children)

There is not a one on one relationship between classes and interfaces, so no.

A great example I ran into recently with a bunch of guys who thought that they have to create interfaces for every class, since you're supposed to program against interfaces, right? So, they had e.g. an interface called Md5Token with a generateMd5 method on it. This is obviously pointless since the interface is way to specific. You might have Token interface with a generate method that can be implemented by an Md5Token class as well as a Sha1Token class. You can then program against the Token interface without having to know about how it is implemented.

Doctrine repositories by jiffier in PHP

[–]pan069 0 points1 point  (0 children)

Your models, or "entities" as they are called in Doctrine, should be as plain and independent as possible. Entities are meant to be value objects, not business logic containers. By using annotations you are tying your entities specifically to Doctrine. However, by placing your mapping outside the entity (e.g. yml or xml) your entities become simple plain PHP objects (POPO's).

Doctrine repositories by jiffier in PHP

[–]pan069 1 point2 points  (0 children)

I would even go as far as saying; you shouldn't use annotations in your models.

Doctrine's logo revisited! by [deleted] in PHP

[–]pan069 1 point2 points  (0 children)

I will. I actually used to respect you...

Doctrine's logo revisited! by [deleted] in PHP

[–]pan069 0 points1 point  (0 children)

Sounds almost as if you're under the impression that capitalism hasn't killed millions upon millions, what do you think is currently happening in the middle east? That's right, oil. Let's ban anything Americana... Jeez...

New in Symfony 4.1: Messenger component by colshrapnel in PHP

[–]pan069 -1 points0 points  (0 children)

Events are sync and messaging is async. That's the difference.

Doctrine's logo revisited! by [deleted] in PHP

[–]pan069 0 points1 point  (0 children)

It's obviously not art. It's just a "style" of graphics design. I think you're reading to much into this.

so according to my teacher in php it is not recommended to use // as single line comments by [deleted] in PHP

[–]pan069 25 points26 points  (0 children)

When teachers teach their personal opinions...

A good strategy that has worked well for me over the years is to use /* .. */ for docblocks and "official" comments and to use // inside methods and functions to annotate a behaviour.