Questions tagged [php]
Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.
                2,059 questions
            
            
            
                0
            
            votes
        
        
            
                0
            
            answers
        
        
            
                26
            
            views
        
        
            
            
        How to namespace global function overrides?
                    In PHP, trim() exists.
By default the second parameter is " \n\r\t\v\x00"
I wish to introduce my own version which doesn't deviate far from the core functionality:
// Trim whitespace in ...
                
            
       
        
            
                3
            
            votes
        
        
            
                3
            
            answers
        
        
            
                230
            
            views
        
        
            
            
            
        Best Practices for Implementing a Heartbeat Feature in a Laravel App to Track Offline Status
                    I'm trying to implement a heartbeat feature for offline tracking that just sends an offline message to the server once the web browser app (Laravel-based) is offline. Ideally it will ping the app's ...
                
            
       
        
            
                3
            
            votes
        
        
            
                1
            
            answer
        
        
            
                189
            
            views
        
        
            
            
            
        How should User behaviour depending on role be design as OOP
                    Imagine I got user which might be either author, administrator, reviewer
An author have relation on book that he wrote.
An administrator have relation on banned user (we track which administrator ...
                
            
       
        
            
                1
            
            vote
        
        
            
                1
            
            answer
        
        
            
                133
            
            views
        
        
            
            
            
        Best practice for integrating UI and dynamic user-specific content using a Flask app
                    I am building a website that uses a recommendation system. Users submit a form which is sent to the backend for the recommendation logic calculation; the recommendation response is sent back to the ...
                
            
       
        
            
                2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                192
            
            views
        
        
            
            
            
        Is widening parameter types in a PHP interface implementation a good practice?
                    I have an interface defined as follows:
interface MyInterface
{
    public function setMyMethod(int $a);
    public function getMyMethod(): int;
}
And I have a class that widens the parameter type:
...
                
            
       
        
            
                -2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                96
            
            views
        
        
            
        PHP secure storage for sensitive document uploads [closed]
                    I need help deciding how to securely store sensitive docs uploaded via a PHP script. I realize I'm not personally qualified for this task (if I was I wouldn't be asking this question) but need to know ...
                
            
       
        
            
                0
            
            votes
        
        
            
                1
            
            answer
        
        
            
                377
            
            views
        
        
            
            
        How to share transaction across multiple repositories in DDD?
                    We are trying the Domain Driven Development (DDD) while working on a project.
We've got a Product aggregate.
We've got a ProductRepository to load/save Products.
We've also got a Timeline aggregate, ...
                
            
       
        
            
                0
            
            votes
        
        
            
                1
            
            answer
        
        
            
                427
            
            views
        
        
            
            
        DTO Interfaces naming convention in PHP
                    It might be that my question would sound a bit stupid but I would like to find the best way for naming my DTO interfaces. In my PHP application I have following DTO types:
Simple (which contains a ...
                
            
       
        
            
                4
            
            votes
        
        
            
                2
            
            answers
        
        
            
                300
            
            views
        
        
            
            
            
        Interface + Trait vs Abstract Class
                    While developing my application I faced an interesting situation:
I have multiple DTO's which are almost identical in terms of methods, only properties are different. For example I have AccountDTO ...
                
            
       
        
            
                1
            
            vote
        
        
            
                1
            
            answer
        
        
            
                216
            
            views
        
        
            
            
            
        DTOs and Single-responsibility principle
                    I'm developing a PHP application and trying to understand DTOs in context of single-responsibility principle. Being more specific, is it a bad practice having helper methods like toArray(), getValue(),...
                
            
       
        
            
                -3
            
            votes
        
        
            
                1
            
            answer
        
        
            
                142
            
            views
        
        
            
            
        Mock an API for development purpose (no testing)
                    If I want to implement a connection from my software to an API, which is documented but not accessible yet, what is a common way to imitate the API until it is available?
My first idea was to mock the ...
                
            
       
        
            
                0
            
            votes
        
        
            
                1
            
            answer
        
        
            
                224
            
            views
        
        
            
            
            
        Our php codes base has 6 different ways to do INSERT … ON DUPLICATE KEY UPDATE, how do I fix it?
                    Our php codes base has 6 different ways to do INSERT … ON DUPLICATE KEY UPDATE. It happened over years because the php framework is evolving and my team members come and go, although I won't say we ...
                
            
       
        
            
                2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                192
            
            views
        
        
            
            
            
        How is $this provided in PHP?
                    I got a fundamental question about the $this keyword in PHP and how it is defined. Pracitcally, I know what it is and what it does. But I am interested in how it is provided / implemented?
For example,...
                
            
       
        
            
                2
            
            votes
        
        
            
                2
            
            answers
        
        
            
                408
            
            views
        
        
            
            
        Unit testing for non-stateless units - how?
                    Firstly let me say I have never written a unit test in my life. I am trying to get the hang of PHPUnit, and so far it's working pretty well for me so far as "stateless" functions (that ...
                
            
       
        
            
                -1
            
            votes
        
        
            
                1
            
            answer
        
        
            
                248
            
            views
        
        
            
            
        Best practices for organising PHP files?
                    I am currently writing a PHP / JavaScript application library, which I intend to use in the future for several other applications. The library includes functionality for handling a database, creating ...
                
            
       
         
         
        