Hot answers tagged

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,498
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

Multi tenancy or multi instance?

I am asking myself the exact same question at the moment. I am leaning towards the multi-instance single tenancy solution but have not taken a definitive decision yet. Let me share some of my ...
Pierre Henry'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
  • 47.7k
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

Consuming REST services: client or server

As is often the case, it depends With a pure JS framework you push a lot of processing to the clients. That means your webserver for the client application will only be serving static files that can ...
JDT's user avatar
  • 6,320
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

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

Multi tenancy or multi instance?

Supporting both options is possible also (a pool of tenants across multiple instances). I favor multi-instance cause of the natural isolation. Each customer's instance runs in it's own processes and ...
Joppe's user avatar
  • 4,566
4 votes

Unit testing Eloquent outside of Laravel

You probably want to test a class that is using an eloquent model rather than the model itself. To create an in memory database for eloquent to query against in your test you want to do create a data ...
Ben's user avatar
  • 141
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

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
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
  • 663
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,709
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

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

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
Accepted

Designing a ticketing system where the User and Administrator have similar but different functionality

Write two different UIs. Really. I work on exactly such a system every day, and the user experience for your User and Administrator personae are completely different. They're different because the ...
Ross Patterson'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
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
  • 203k
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

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

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

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