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

learn more… | top users | synonyms

0
votes
0answers
58 views

How to handle 301 redirection loops?

I'm working on custom 301 redirect module. I am getting a redirection loop if source url == www.xyz.com/aboutus/*.php and destination url == www.xyz.com/aboutus/xyz.php or source url = /abc/* and ...
1
vote
4answers
253 views

How to deal with long running transactions?

I'm developing a Content Management System (CMS) and I would like to include a "Save Changes" button. I mean: a user performs several changes in the database, but those changes are still not ...
0
votes
1answer
128 views

Child classes only change some “options” - what's the best approach?

I'm currently implementing functionality in Symfony (PHP - not that it should make any difference which language I'm using) where I have about four controllers that do almost exactly the same thing. ...
0
votes
0answers
36 views

MVC single view file with multiple uses depending on passed in value

I'm using Laravel with Blade to build a simple maintenance application for my work. One of the functions of the application is to display simple statistics for a piece of machinery. To keep things ...
-1
votes
4answers
405 views

Why do negative numbers evaluate to true in PHP? [closed]

function haha($lol) { if($lol) { echo "plus"; } else { echo "minus"; } } haha(-1) echoes plus. Is it because PHP uses twos complement? Google search wasn't really helpful.
3
votes
2answers
103 views

Best way to develop new features as well as fix any bugs for a web system on Windows [closed]

I'm a one-man band and I have a contract with a client to develop and maintain a web-based system that is relied upon. This is the first project of this size and type that I have done for anyone else ...
-1
votes
1answer
150 views

Understaing the “fillable” in Laravel migration [closed]

Using models is one the best facts in Laravel, but when using a model, it is not like my "native" environment (J2EE, models declare all DB table colums), it has three variable, and which of them is ...
0
votes
0answers
31 views

Kind of Servlet (J2EE) for PHP?

I'm coming from a J2EE development environment, and by there, I used a Servlet context to hold all the website meta data (title, description ...) for the whole application (some kind of a session for ...
0
votes
1answer
87 views

How to split a class that is an implementation of interface?

Let's say there is class called AccountingService. Using this class I fetch all kinds of ecommerce records like products, customers, etc. The fetching happens inside a controller action. Once fetched, ...
0
votes
1answer
1k views

Folder structure for app with Symfony 2, React, Webpack, and Sass? [closed]

I am creating an app that uses some components of Symfony2 along with React, Webpack and Sass. We will mostly code in PHP, with the other things adding functionality to our app. I'm having a hard time ...
0
votes
2answers
138 views

Incrementing Strings in PHP (and Perl)

PHP allows you to increment strings. Why? Let's jump ahead a bit. Take the following code: $string = '9ZzZ'; echo ++$string; // 10AaA From a purist point of view this may seem like nonsense, ...
0
votes
1answer
129 views

Can I execute a query in a catch block of try-catch? [duplicate]

I want to confirm the right approach of using try-catch exception handler. I have written a query in a try block, and if any exception is thrown, it will execute a query in a catch block. Is this ...
0
votes
2answers
109 views

REST Service Description in a Hypermedia agnostic way?

How do I implement REST service description in a Content-type agnostic way? Background I am developing a RESTful API for Web Application. Now this app is somewhat different than a standard ...
0
votes
1answer
185 views

Efficient way to store large number of image path per record into a database table? [closed]

I am trying to think of an efficient way to achieve this. We get a zip file that has a XML file containing around 1500-2000 items. Each of the item could have up to 20 images for it. The images are ...
4
votes
3answers
366 views

Name of this pattern to wrap functionality

I have a system that allows certain functionality to be implemented different ways, but requires that the functionality of each implementing class be wrapped in another layer. For example, each ...
0
votes
0answers
75 views

Broadcasting events asynchronously in a high frequency application to prevent hangs?

I'm doing a bit of socket.io work in an application that demands high frequency updates with minimal wait times (imagine a commentator annotating a video livestream, with viewers both watching the ...
1
vote
1answer
379 views

Array vs Object for View in Laravel

First, yes This question is very similar to Arrays vs Objects in view template but my question sort of expands on this... When deciding on whether to use an object or array to pass data to your view. ...
0
votes
2answers
134 views

What is a readable algorithm for selecting a random buyer based on what they purchased?

I am working on a giveaway algorithm to select a customer based on what they purchased: If they purchase item 1, they gain 1 point. If they purchase item 2, they gain 2 points. If they purchase item ...
2
votes
1answer
171 views

Explain ServiceLocator pattern of ZF2

I am looking at this example: http://framework.zend.com/manual/current/en/user-guide/database-and-models.html Relevant excerpt from above: class AlbumController { public function ...
0
votes
1answer
258 views

Tracking hours with clock in/out

I am working on a web interface that would allow the user to keep track of the amount of time people spend at their establishment. The problem: I don't know what the best way to keep track of this ...
3
votes
2answers
321 views

Roles and permissions: a good approach in defining permissions?

My application has users and administrators. The administrators split into two: super-admin and limited-admin. The super gets all permissions while the limited can be configured to inherit just the ...
1
vote
1answer
187 views

PHPDoc Comment, Class vs File

I am trying to standardise my code as much as possible, including DocComments, using PHPCS. It seems that the PEAR standards contain two sniffs that require almost exactly the same tags appear in the ...
0
votes
1answer
128 views

Best pattern to write a PHP function that checks on access and returns more then boolean?

I'm prototyping behaviour of a new application, and want to write some functions that check on access based on some variable dates. I just want to write separate functions for that, like ...
0
votes
1answer
157 views

Coding to an interface vs more generic interfaces

I have a number of classes (and interfaces) which 'code to an interface' interface File { ... } interface FileConverter { public function convert(File $file); //coding to an interface ...
2
votes
1answer
79 views

Reusing an interface or method chaining

I am learning about coding to an interface in OOP programming. I understand you should code to an interface so you can 'swap out' functionality. However, I have a situation where I feel I can reuse ...
1
vote
0answers
114 views

Are facilities that generate HTML for you, considered harmful? [closed]

I will approach this from two directions (+ raw HTML itself being de-facto third) Proprietary HTML-generating code Code generating facilities provided by a popular library Proprietary ...
1
vote
1answer
202 views

Synchronize database with external API

I currently own a website where players can look-up their statistics of a game. When someone that is not in my database yet requests their statistics, I am calling the API with a PHP cURL request and ...
1
vote
0answers
55 views

Storing reference to a model obtained using DataMapper to be able to call save on it

When using the DataMapper pattern, which involves modeling classes containing business logic and knowing absolutely nothing about persistence, caching,... I usually want the models to represent ...
1
vote
0answers
47 views

Recursive(?) algorithm design help

I have a requirement to allow my end users to input formula much like a spreadsheet. I have an array like this: $table = array( 1=>array( "id"=>1, ...
0
votes
2answers
286 views

Are hooks really subsumed by Slim Framework middleware?

I've been using the Slim Framework (v2) for a little while now to develop my user management system. They recently released Slim 3, and according to the upgrade guide, Slim v3 no longer has the ...
2
votes
0answers
152 views

Why do some top projects require write permission on code itself? [closed]

Well this could be a very wide question as every project have different philosophies. But meanwhile question is that We have lot of projects like Yii, Drupal, Apigility which requires full write ...
1
vote
1answer
85 views

Access container object from within an item

Generally I have 3 classes, a container that holds an array of items and a special object that is another property of the container class. What I need to do is access the special object from an item ...
2
votes
0answers
50 views

Where to output from large CLI app [closed]

I've built a reasonably sized CLI app with everything split across different classes and namespaces in a logical way. However many components need to render output from within themselves. Which seems ...
3
votes
2answers
141 views

How to accomplish a task of evaluating editable variables and formulas, using PHP?

Task as defined: User needs to be able to define their own variables and formulas to operate on those variables, to get output based on their inputs. Since formulas and variables and their inputs ...
2
votes
0answers
66 views

Standard for order of tags in PHP DocBlocks?

Based on the tags listed from this "standard", is there an order of the tags that people typically follow? Even if it's not something that has been entirely accepted, but something proposed? I am ...
0
votes
1answer
126 views

PHP MySQL unique user data [closed]

I'm trying to create a php website that users log into and they can submit data to a MySQL database. How do I make it so the users can only see data they've submitted and not everyone else's data? ...
0
votes
0answers
102 views

Correct way of running methods from frontend in an OOP framework

If I have a link to change language of my website, where should that link lead in order to execute a PHP command, specifically in Codeigniter framework? I am interested in the most recommended, DRY ...
0
votes
0answers
84 views

Test for PHP Errors using Browser Emulator (Mink)

I want to know the most robust way of checking for PHP error messages when running automated tests that interact with a PHP application via a browser emulator. The reason is: I use Behat, Mink and ...
4
votes
2answers
252 views

Is trait composition an good practice?

So, I am now dealing with this relatively new codebase which uses, and sometimes feels like it abuses traits. Since I have been exposed to trait usage in a rather limited fashion, I was wondering ...
1
vote
1answer
144 views

Storing PageViews Count Data in MongoDB

I would like to ask for feedback for some programming logic concept & ideas. I am building a site where i would like to keep track on how many pageviews a page has daily. I have thought of 2 ways ...
2
votes
0answers
151 views

PHP Vertical Columns from 3 SQL Tables

I work at a high needs school in which there are several classes that plan their work through Excel spread sheets grading and tracking student progress. We have come to the conclusion that this ...
3
votes
1answer
166 views

How do SQL transactions return immediate results?

I am using transactions to do bulk insert/updates. This is my little test loop: $now = date('Y-m-d H:i:s'); for ($i=0; $i<60; $i++) { $db->insert($cfg['ps_manufacturer'], array( ...
3
votes
5answers
347 views

Inheritance when following the Repository Pattern in PHP

I am trying to build a PHP application using the Repository Pattern but I'm not sure how I should implement the save method. I have an abstract class called ItemRepository which have the following ...
0
votes
1answer
63 views

When is the best time to compute rating changes in a PHP application?

Imagine a simple PHP application where an user can post notes and the other users can upvote or downvote them. We want to implement a system where each note has a different rating (normal, good, ...
0
votes
2answers
150 views

read file bytewise and find information

i am a hobby php-dev and have the following problem: i have a rar-file, whose header is damaged, therefor extracting is not fully possible. the contents are non-compressed, and can be read with eg. a ...
0
votes
3answers
205 views

call function once again after failure, without duplicate lines?

I have what is probably an over-engineering question. I have some PHP code that logs messages to a file. We've been having a problem with the file having the wrong perms from time to time. While we're ...
12
votes
1answer
2k views

PHP: when to use arrays, and when to use objects for mostly-data-storing code constructs?

PHP is a mixed paradigm language, allowing to use and return non-object data types, such as arrays. I pose a question to try to clarify some guidelines for selection of arrays vs objects when deciding ...
1
vote
2answers
567 views

Alternatives to cron jobs or other ways of improving scheduled task performance

I'm working on a social networking website where users gain ratings after specific actions taken and proper conditions are met on the tables. The ratings are calculated depending on 'total hours ...
-1
votes
2answers
345 views

How are complex programs made? [duplicate]

I know a few languages, and can program in them. How do multiple languages blend together in a single program? For ex. https://github.com/facebook/watchman. This uses C, PHP, Python, Javascript, etc. ...
0
votes
1answer
177 views

What is the problem will happen if I create auto generate ID without using mysql auto increase of mysql table by my self?

I would like to ask you a question about MySQL AUTO_INCREMENT. I already created my own function to generate AUTO_INCREMENT when the user inserts any data input a table in MySQL. This function works ...