9 votes

Necessity of TDD in web application development

If you are starting a greenfield project I would urge to start automated testing from the start. Doing everything TDD might be a challenge if the team has low experience with TDD. Still setting a ...
Niels van Reijmersdal's user avatar
9 votes

Should on each test create and nuke a testing database?

Tests should be independent of each other and reproduceble. This can be done with complete database setup for every test as you described or with a predefined database-content where a database-...
k3b's user avatar
  • 7,528
8 votes

Using multiple languages

The usual way to support multiple languages is to find some way for the two to talk to each other. This is very common in the web world; you might have a ROR site talking to an Android application. ...
Robert Harvey's user avatar
8 votes
Accepted

Service Design Pattern

Sorry for the C# syntax, I'm not a PHP dev. But the core of the answer is language-agnostic, and I hope the syntax is readable enough for you to understand the focus of the examples. You've actually ...
Flater's user avatar
  • 49.9k
7 votes

Should I use foreign keys in my database if I use laravel?

The data belongs to the organization, not the application. While right now you're using Laravel exclusively, in the future there might be several applications interacting with the database. I'm ...
Andrew's user avatar
  • 681
7 votes

Should I use foreign keys in my database if I use laravel?

Foreign keys in your database enables data integrity, as you can't delete a parent row if there is a child row in another table. While you can rely on the framework to handle data for you, the ...
Juan Ligero's user avatar
6 votes
Accepted

Laravel Eloquent - Filtering results and eager loaded results

You're confusing whereHas and with. The with method will let you load the relationship only if the query returns true. The whereHas method will let you get only the models which have the relationship ...
Steve Chamaillard's user avatar
5 votes
Accepted

Laravel 5.2 - Better to create a Service Provider or Helper class or otherwise?

It is all a bit of semantics. A service would be a helper class, or in a sense a helper class would be a service. In terms of Laravel. Creating a service (which is a specific thing) would help code ...
Jeremy French's user avatar
5 votes

Is it bad practice to have lots of Models Views and Controllers?

I would not fault you for having three different controllers; there is absolutely nothing wrong with that. However, if you are feeling the need put each comment type in its own controller, there is a ...
TheCatWhisperer's user avatar
5 votes

Push notification from web application to my mobile app

There is no need to reinvent the wheel and there are plenty of solutions out there that makes pushing notifications to mobile devices easier. I personally would recommend Firebase Cloud Messaging by ...
Dean Meehan's user avatar
4 votes
Accepted

RESTful api and nested resources

If you are designing L3 maturity API (HATEOAS) [1], clients do not build or remember URLs. The best approach in this case is to have multiple mappings to support both scenarios: fetching by navigation ...
Ivan Gammel's user avatar
  • 1,226
4 votes

Dependency Injection via Constructor vs Setter

I think that your Foo class should not depend on a Personable instance. Your Foo class probably has a number of methods that you can call to make it perform some actions using the Personable object, ...
Thijs Riezebeek's user avatar
4 votes
Accepted

TDD workflow with integration testing

It can be a bit overwhelming trying to come up with the right balance for your project. I'd like to help you with a framework of how to put it all in place. It starts with the customer Your product ...
Berin Loritsch's user avatar
4 votes

Is this a 'proper' use of a trait in PHP?

Far from being an expert, but I had the same question in mind for a while as well. This is what I have gathered. The generic (across languages) definition does emphasize that a trait can extend the ...
farhang's user avatar
  • 141
4 votes
Accepted

Data is in database or get from API, where should API request code goes?

In my opinion, you should add another abstract layer (for example, a repository) between the model and the client using it. I think it's better if we keep the model clean from infrastructure related ...
Hieu Le's user avatar
  • 673
4 votes

Placing business logic on a not so small/big project

We’ve learned over the years that most small projects grow over time. What starts as simple CRUD applications evolve into business critical systems and complexity increases exponentially. Sooner or ...
Rik D's user avatar
  • 4,791
3 votes

Necessity of TDD in web application development

Strict Test Driven Development requires the test for the next bit of code to be written before the tested code is written. In this way, the attempt to use the API positively influences the development ...
Frank Hileman's user avatar
3 votes
Accepted

Best architecture for a Laravel app with a frontend (users) and backend (admins only)

It's far more common to have one app and one users table. Look at any CMS out there (Wordpress, Joomla, forum software) - admins are always just regular users with additional privileges. In Laravel ...
DisgruntledGoat's user avatar
3 votes
Accepted

Queue how to preserve requests?

I found the problem. Yes I must save the Eloquent model (if using a eloquent model) injected in JOB. Reading better the documentation says: "If your queued job accepts an Eloquent model in its ...
koalaok's user avatar
  • 503
3 votes
Accepted

How to improve version control on database structure when migrations take long?

Your version control strategy seems fine, you just need a performance optimization for your migrations. You wrote Soon we find that some old project takes long time in running the migration file ...
Doc Brown's user avatar
  • 208k
3 votes

Advantages and disadvantages of building web app purely with microservices and hybrid with web framework

Frameworks have come a long way. They're very powerful and get amazing things done. They've also become so ingrained into the languages they work with that employers have to mention them when ...
candied_orange's user avatar
3 votes

Using multiple languages

One way is to explore micro-services. In this case, you can have part of your application written in, for instance, PHP, and other part of the application written in RoR. These two applications ...
Gustavo Pinto's user avatar
3 votes

How to prevent multiple form submissions when user reloads the page

I have answered this question on StackOverflow as well - I place my answer here for easy reference... The PRG pattern alone will not prevent this, as the P action in it takes time (which is usually ...
Daffy Punk's user avatar
3 votes

HTTP Query String vs URL Parameter for referral codes

This form www.example.com/invite/123 is preferable when your URL refers to something concrete and specific, like a business entity, transaction or document. The word "invite" typically refers to a ...
Robert Harvey's user avatar
3 votes

Caching Layer in libraries: what's the most correct design?

Preface: I know you are asking about PHP. I have no PHP experience but here is what I would do as a Java developer. I do not know how relevant this makes my answer. You wrote: I would like to ...
Ivan's user avatar
  • 575
3 votes

Is there a coding style for Blade templates?

This often relies on preferences. BLADE doesn't have any special coding standards that differ from standard PHP in HTML. If you work in a company, there might be some standard set to keep the code ...
dynero's user avatar
  • 141
3 votes
Accepted

Use same API for both website and other clients or not?

This is a general answer, and may or may not apply to your specific use case. Remember to always think about architectural decisions, as there is no "one size fits all." Typically, I would use the ...
Marshall Tigerus's user avatar
3 votes
Accepted

PHP - Designing a rule based parsing engine

From my standpoint, we can improve your solution a little bit Add the order column to the parsing_rules table Because the list of rules is an ordered list, we need to save the index of each stage to ...
Hieu Le's user avatar
  • 673
3 votes
Accepted

Is it considered as best practice to use migration scripts for one-off large data manipulation over a table?

There is nothing wrong in providing default values for certain or all records immediately when new columns are added to a database table. In fact, this could be mandatory to bring the system to a ...
Doc Brown's user avatar
  • 208k

Only top scored, non community-wiki answers of a minimum length are eligible