Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.

learn more… | top users | synonyms

-3
votes
0answers
16 views

Database Structure for Agents commission payouts generation with TDS deduction

Actually I am creating this for the first time to generate the commission payouts for agents for their sale. Commission need to be generated when the product is sold out and payout need to be done ...
-3
votes
0answers
25 views

Working with large data sets on Php and Excel

I need to deal with larger datset in my upcoming project, so choosing a good tech for the same will be good. As we say "Right tool for right job" Project will be dealing with Large data sets, ...
1
vote
0answers
50 views

Child class accessing its parent's method from Ancestor method

I find myself right now banging my head with the following issue (in PHP): I have an abstract base class, which has a non-abstract method, inherited and unchanged all over the inheritance chain ...
-3
votes
0answers
25 views

List aggregator web application

I was looking to build a small web app to list pictures by group (ex. fruits, animals, cakes, etc.). Then allowing each user to select from the various lists and create their own master list from the ...
2
votes
2answers
105 views

Unit Testing and 3rd party packages. Do I mock or not?

I'm just getting used to unit testing and on my new project I decided to adopt a TDD approach. My code below is to test the UserServices class which is responsible for creating a user, deleting a ...
1
vote
2answers
55 views

Does my code still break encapsulation and uses getters/setters instead of the TellDontAsk principle?

I and one guy have been discussing potential solution of a problem on an unrelated board, regarding the typical getter/setter hate, ie. using getters/setters leads to procedural programming. I ...
0
votes
1answer
99 views

Why use PDO's rowCount() if I can just use PHP's count()?

So in PHP, there's PDO to fetch things from a database. Now I see a bunch of $stmt->rowCount() calls in the code I'm working with. Why not just fetch the result array and throw a PHP count() over ...
-1
votes
0answers
18 views

grocery crud with codeigniter manage n-n realationship between three tables?

the database has four tables to implement cars features and values of this feature I create a trigger that adds all features to the table 'feature_has_value' after adding new car and give each ...
-3
votes
0answers
19 views

Create specific social network with blog posts - CMS or framework? [on hold]

I'm thinking of creating social network where every user can add blog posts (PHP). It will be a dream journal, like www.dreamjournal.net, but it should be completely translated to local language ...
1
vote
1answer
58 views

Best practice for settings for PHP class for code generation

I would like to have a class create any code from given options and output it in a chosen way. Background I have written class for generation of simple JavaScript code for such cases where is needed ...
-2
votes
0answers
15 views

Accumulation Timestamp with Codeigniter and Grocery CRUD

I have questions because i'm tired to find my problem. my problem is a accumulation in codeigniter make plugin grocery crud. i'm can't accumulation with code : public function isp_management() { ...
0
votes
2answers
70 views

Undo/redo implementation for file changes in PHP

I was thinking to store all file operations inside an array, along with the reverse operations which are used for undos. Example: [ [ 'op' => 'move', 'parameters' => [$path_from, ...
2
votes
1answer
80 views

How far do I, or can I take TDD tests with Service Objects?

In writing PHPSPEC tests for a Zend Framework 2 application, I'm left wondering how far to 'dig'. Consider this very simple case: A DomainService (Domain in the URL sense of the word) should be ...
-4
votes
0answers
24 views

Check with PHP DANE or TLS [on hold]

I want to know, if there is a way to check with PHP if a domain support DANE and/or use for encryption TLS? I want to build a little validator for to check domains.
0
votes
1answer
113 views

Consuming REST services: client or server

I am working on a new project in which we are currently deciding which technologies and frameworks we will be using. The application will eventually be cross platform. Therefore, for the server side, ...
14
votes
3answers
4k views

Is it good practice to avoid warnings and notices?

I've generally been working with PHP warnings and notices off, since I work on a lot of projects where it's already in live production. Now, if I turn on the warnings and notices on these live ...
-1
votes
0answers
19 views

Store SQL queries in the database or in the server script? [duplicate]

I used to do queries from PHP by manually making a query string like "SELECT * FROM ... WHERE ... AND ...", but my office does it by making stored procedures in the database and just querying "CALL ...
0
votes
1answer
57 views

static method, helper function or in the controller, where does this go?

I'm working on a piece of functionality that simply allows a guest user to perform an action a certain number of times before requiring them to login\create account. In this instance, they can vote on ...
6
votes
6answers
238 views

Should I always store parsed data in database before manipulating?

I am about to start a new project which involves taking an excel file, parsing the data (php-excel-reader) and then using the parsed values in a HTML email. My question is pretty simple. Is it better ...
0
votes
0answers
19 views

Better way to build SQL query from form input? [migrated]

Very new to php. Using XAMPP, netbeans. I am using a <form> to send various input parameters as a GET to retrieve data from a very simple two table MySQL db. After filtering the inputs ...
0
votes
1answer
167 views

Confusion over Node as a “script” vs Node as a “server”

As I was beginning to tool around a bit with node, I was told that I needed to undergo a little bit of a paradigm shift since I was coming from a PHP background. I would ask questions like, "I have my ...
0
votes
1answer
72 views

Strategy for Public / Private API, Encrypted (or Hashed) Data, and Server Compromise

In this very simplistic but realistic scenario, I have 2 combo web/database servers (A) behind a load balancer and a single IP address. They also permit access only from one IP address -- the client ...
5
votes
0answers
57 views

Algorithm to generate Edges and Vertexes outwards from origin with max multiplicity of 3

I am creating a 2d game for a website where the universe can grow extremely large (basically infinitely large). Initially, the universe is composed of 6 stars that are an equal distance from the ...
3
votes
2answers
147 views

How are POST/PUT/DELETE data passed to APIs?

I know that the data is passed through HTTP, but I'm not sure if I should be passing data through HTTP headers, or HTTP bodies. Which one is the convention for APIs? Also, theoretically using PHP, ...
3
votes
2answers
164 views

Implementing “buy one get one for free” coupon logic for shopping cart

Trying to solve bogo coupon logic with proper design pattern, but having trouble identifying one. Use case: "Buy iPad get SmartCase for free" Suppose we have the following objects: Product: - ...
2
votes
4answers
234 views

How to properly reverse the if statement when you have two conditions in it?

In PHP I have this if statement ( $first and $second will evaluate to true or false): if ($first && $second) { // evereything is OK } else { throw new Exception()... } My real code ...
0
votes
0answers
24 views

How to call non-static methods statically within the same class (not strict mode) [migrated]

We have a library that uses a lot of static methods. However, this has made testing in PHPUnit difficult as I cannot mock those static method calls. So, I'm in the process of removing the static ...
3
votes
3answers
146 views

Are exceptions only for handling errors?

I have a script that throws exceptions when something goes wrong. However, for the purposes of testing I also want to capture specific points although I'm not sure whether they would be deemed errors ...
0
votes
1answer
182 views

Is PHP7 a static or dynamic typed language? [closed]

In the past few years, we've been using dynamically typed versions of PHP. However, in PHP7 we have an option to enable 'strict types': PHP RFC: Return Type Declarations PHP RFC: Scalar Type ...
0
votes
2answers
163 views

How to analyze a code of a web application which is running? [closed]

Joshua Bloch said in an interview that the best way to know and understand code written by others is to read it, mentally or through a debugger. Well, my question is this: is it possible, through a ...
0
votes
2answers
77 views

How to simulate method overloading in langs without such feature? [closed]

Langs like Java knows about true method overloading: class Overload { void demo (int a) { System.out.println ("a: " + a); } void demo (int a, int b) { System.out.println ("a and b: " + a ...
1
vote
0answers
96 views

Can this be used to implement Post Redirect Get pattern?

I am trying to implement proper a Post Redirect Get on a PHP site (question is language agnostic in nature however). I thought about it, and realized that running this code on every request seems to ...
0
votes
1answer
72 views

Why use PHP_AUTH_USER instead of taking credentials under post method

What would be the advantages of using PHP_AUTH_USER and PHP_AUTH_PW instead of the verifying the credentials under method - post . Why i should use: $_SERVER["PHP_AUTH_USER"]; and ...
1
vote
1answer
69 views

How can I create a client for a service without hiding the parameters needed for each endpoint?

I'm creating a client to a third-party soap web service in my application. Here is the way I'm thinking of doing it: Create a ClientFactory that makes a client based on the wsdl file, and sets ...
16
votes
2answers
1k views

Is it a good idea to define one big private function in a class to maintain valid state, that is, to update the object's data members?

Although in the code below a simple single item purchase in an e-commerce site is used, my general question is about updating all data members to keep an object's data in valid state at all times. I ...
2
votes
2answers
175 views

Is equating a variable to a function that takes the same variable bad programming?

Is it improper programming to set a variable equal to the result of a function that accepts the same variable? The languages in question here are c#, javascript and PHP (not sure if this works in C ...
3
votes
1answer
88 views

why use authentication token instead of session_id for app(android side) in REST API

in normal php web application after login we use session_id that came from web browser to check if user loged in or not. But in REST API authentication I read some tutorials that say php should send ...
2
votes
2answers
96 views

Best approach to develop php mysql project with multiple developers

We are 4 developers working on a PHP-mySQL web project. Currently we work together as described below: All project files except DB is hosted at GitHub All project files except DB is hosted at GitHub ...
6
votes
2answers
134 views

Advice for designing API request rate limiter?

I'm in the planning stages of a web application that makes heavy use of data retrieved from a third party's REST API. This data is cached on the server and requested by clients via AJAX. The REST API ...
0
votes
1answer
180 views

PHP framework advice needed [closed]

I started PHP programming around 2002, when there were not that many frameworks around. Over the years, I developed my own PHP framework, which seems to be entirely different from any standard I come ...
-2
votes
2answers
105 views

All methods in one file/class versus multiple files/classes [duplicate]

This question is mainly talking about PHP, but I think it can be applicable to other languages as well. This is a question about code organization. I have a friend who insists the best approach ...
-1
votes
2answers
116 views

What technique can I use to test my code when code renders out an untestable(?) PDF document?

I have a need to test output of my code before I send the output for PDF rendering. Currently I have decided on a switch statement that does two different things depending on whether I am in ...
0
votes
1answer
62 views

Abstract classes with static methods in PHP

Pre: I am looking at a quite big PHP project developed by a company which we need to partly interact with while building a new webapp. The whole application is developed in PHP 5. Most of the ...
0
votes
1answer
176 views

What is the name of this design pattern?

Magento has a class called Varien_Object with a pattern I'm trying to identify. The pattern creates hidden data and allows access to it but the main difference between this and a normal facade is ...
0
votes
2answers
145 views

Integration Tests - How much is too much? [duplicate]

First of I'm not sure if I chose the right name for my question, I'm not sure if they are functional tests or integration ( or other ). I'm talking about tests which test (or it should) the app from ...
3
votes
2answers
94 views

Best practice in helper/util methods: IoC container or static methods?

So I'm developing an application which is using an IoC container. Now I need some helper methods for array manipulation like set, get, etc. I see two possible ways to go: Using a class with static ...
-1
votes
1answer
99 views

PHP: where to call helper class in MVC?

I've a helper class in Laravel 5.1 with static methods for calculating week numbers, dates in weeks, etc. (Why static? I need max. 1 instance of this helper class) I need this logic in my views. I'm ...
3
votes
1answer
120 views

Can this be considered an API? [closed]

I'm writing my first API, but I think I screwed it up from the design. It's a simple CRUD API which behave like this: READ: /api/data gets redirected to api.php?data1=data. POST variables: user, ...
1
vote
1answer
150 views

How harmful is using switch(true) as a way to handle multiple conditional statements? [duplicate]

I recently saw something like the following: switch(true) { case iAmAmazing(): { return 'some html'; } case isVariable: { return 'some other html'; } case ...
-1
votes
0answers
24 views

oauth2, grant types, and mobile apps [closed]

I'm implementing a webservice which utilises oauth2 Specifically using this library: http://bshaffer.github.io/oauth2-server-php-docs/ I have the beginnings of an android app that will access the ...