Tagged Questions

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

learn more… | top users | synonyms

1
vote
3answers
363 views

PHP Code base design: Single “queries.php” file, or spread queries across different php files/classes?

When I create PHP projects, is it better to put all database (e.g. MySql) queries in a single file (i.e. "queries.php")? Or is it better to place the respective queries in any "model" classes (i.e. ...
-1
votes
1answer
182 views

Building a webservice with mvc [closed]

I'am planning my website over here based on MVC. And I am thinking about a webservice (who knows, maybe one day I'll create an android app or something). The site and the webservice will behave ...
0
votes
2answers
222 views

mysql, store a single piece of data per row

I am preparing to write a database system using PHP and MYSQL which will store every piece of info sent to it as an individual row. Each row will store several piece of meta data (time stamp, who ...
3
votes
3answers
265 views

OOP what is meant by object-to-object communication

I've been reading in basic concepts of OOP,as i'm trying to make this shift from transactional scripts to more oop manner in php, and i often come across this definition : An object stores its ...
0
votes
2answers
182 views

Examples of designing a database that handles point tracking?

I'm attempting to expand my knowledge of how database designs and concepts work. I'm working on a hobby web/mobile app for practice that will challenge me. However, I am running into an issue. What ...
0
votes
1answer
283 views

How can I deal with a slow API in PHP?

I'm writing a public web app to get stock data from a magento store. I've accessed the data, but it turns out that i have to query each product individually for stock data. With thousands of items ...
6
votes
2answers
315 views

Slight extension for SQL prepared statements syntax. Need advice

In my database abstraction library I am extending SQL prepared statements syntax to hint a parser with expected literal type. I take it as a very essential improvement, my reasoning you can read here. ...
0
votes
1answer
582 views

I'm thinking to CSRF protect all public AJAX requests that return JSON, but I have some concerns

I'm thinking to CSRF protect all public AJAX requests that return JSON, because what's to prevent another site from spoofing the AJAX header and using the JSON as if it were a public API? I think CSRF ...
0
votes
2answers
164 views

Best design pattern for library with data model

I am refactoring an old Codeigniter library to be php framework agnostic. There are these core parts: the connection object - this will come from the "user"; ie, the framework's connection, or their ...
0
votes
0answers
114 views

Customizing configuration for PHP will Laravel 4 IoC be useful?

This topic has been discussed in this post: Customizing configuration with Dependency Injection However - I couldn't find one for PHP syntax and since one of the answers was to use a specific ASP.net ...
1
vote
1answer
420 views

Avoid code repetition in CRUD operations

I'm developing a PHP application and I find myself doing basically the same code for, say, creating an object based on a form filled by the user. The objects are of different classes, but the process ...
2
votes
3answers
537 views

Design for creating a menu based on user type

Problem I am building a PHP application which has a main menu, which in turn contains various "sections" or "subheadings" with various links. There are several user types such as SuperAdmin, Admin, ...
0
votes
1answer
52 views

Testing the Consumers of Subclassed Data Structures

PHP's SplQueue does not include a clear() or reset() function to wipe data out of the data structure. My application requires that functionality. This leaves two options: A) Create a subclass of ...
1
vote
1answer
153 views

Web design pattern

I am building a small website, in PHP and I am using MVC design pattern for the UI. In the future I will need to add mobile support for my website. It will be in the sub domain "m" like everyone. All ...
-2
votes
1answer
4k views

Advantages and disadvantages of PHP/Ruby [closed]

I've been a front-end developer for about two years now, and I'm attempting to break into the server side of things. Ideally I'd like to work for a startup social network on the back-end side so I ...
0
votes
1answer
1k views

Online and offline point of sales application [closed]

I am going to develop a simple Point of Sales system. Mainly all the data will be stored in a central db (mysql server). All the application are going to be winforms. Together each local client will ...
5
votes
2answers
200 views

Branch twice for unique condition

Consider an application that displays only Foobars belonging to themselves to normal users, and all Foobars to admins: -- Normal users: SELECT * FROM Foobar WHERE user_id=:user_id; -- Admins: SELECT ...
0
votes
2answers
169 views

Is it better to use already build plugins/extensions or code your own in programming projects [duplicate]

I am building a web app in PHP and Symfony. Basically if we search there are plugins / extensions / bundles for almost 60% of stuff. The advantage of using them is that you can easily get your ...
1
vote
2answers
173 views

Minimize touching the already-working code when a radical change is required

I have a code that highly relies on an Array structure like the following: $array['customer'][$customer_id]['details'][..]; // it goes to about 10 levels deep However, after almost two years ...
0
votes
1answer
363 views

Does it make sense to break fluid interface if a bad argument is passed?

If I chain some setters together and one of them does not return $this, then I will get a fatal error. But maybe that is a good thing. $object = new object(); ...
0
votes
1answer
62 views

Method to store some site content data, allowing reusability

(Don't believe this is a "best practice" question as I believe there will be a single better choice). I need to choose a data storage option to store specific site data to allow easy management and ...
1
vote
2answers
119 views

How to annotate method signature changes?

I'm developing a mini framework and I want to perform changes to existing methods. I know in order to deprecate a method I can use the @deprecated annotation. However, what annotation should I use to ...
0
votes
1answer
51 views

Mail Server Caching

I'm currently working on a web mail client. When a user logs in, I'm fetching all the mails from the INBOX from the beginning of time. As expected this is pretty darn slow. I'm planning to implement ...
2
votes
2answers
125 views

Handling login errors with User Class

We have a User class which handles all things related to users within a Content Management System. As you'd expect, the class contains a function login(). This function accepts three arguments: ...
0
votes
1answer
127 views

How to define constants with PECL hidef?

I've recently convinced the team that we could upgrade from php5.4 to 5.5 -- but, unfortunately, it seems I overlooked that php-apc is no longer supported in php 5.5 -- which is fine and dandy, but we ...
0
votes
0answers
52 views

Algorithm for Testing interoperability

I am writing a php script that carries out a task. One input is a list of options that I need to test for interoperability. If the options are A B C then I need to test every combination, but I only ...
1
vote
1answer
121 views

Need help modelling a User/Project/Task relationship

So I'm creating a very simple project/task management application in Laravel 4 and I'm not sure how these relationships would work. I have a Project, Task and User model. A User can own a Project or ...
0
votes
1answer
150 views

Should I save a simple list cookie in Javascript or PHP?

I am currently making a simple list tool. You can click a checkbox to mark it as done and if you navigate away from the page/close the browser and reload, it will still be saved. So it's pretty much ...
1
vote
3answers
231 views

Quoting for a project with closed source

I sit with a project that I need to quote, and until the job is awarded, I can only use "View source" to check, and ask a few questions about the system. That makes quoting outright impossible for me ...
0
votes
3answers
189 views

Doesn’t active record violate SRP and OCP?

I have watched the active record classes in our project grow into large, do-it-all classes. When you need anything about a user, for example, you should go to the Person class. While this makes ...
0
votes
2answers
397 views

“Match Making” script, a way without involving the database and php?

I am writing a matchmaking script for a game through a web portal. For the past few days I have been looking into the different options and I believe the following approach would be the most optimal ...
1
vote
3answers
2k views

how to check email address exist or not in php

I have tried a lot but could not find a way by which I will find if an email id exists or not. My problem is that I do not want to make visitor to email me with fake email Id. Is there any solution ...
1
vote
6answers
814 views

An alternative to an array of functions?

I'm programming an app (php) which requires a very long list of similar yet different functions, which are being called by a set of keys: $functions = [ "do this" => function() { // ...
0
votes
1answer
81 views

debugging web applications using debug parameter

A suggestion has been made by a team member to leave all debug code intact in our web pages... and then to create a variable that can be turned on / off to enable / disable debugging. This is a ...
0
votes
1answer
204 views

Practical Use of Depency Injection (IoC) Container

I am creating a MVC-ish framework in PHP. I am trying to implement a DI Container to allow the creation of controller objects (among others). My MVC framework is pretty typical. Each module (or ...
1
vote
2answers
218 views

Updating an Entity through a Service

I'm separating my software into three main layers (maybe tiers would be a better term): Presentation ('Views') Business logic ('Services' and 'Repositories') Data access ('Entities' (e.g. ...
0
votes
7answers
422 views

Developing only for 64 bit servers a bad idea?

In an attempt to solve one problem I encountered another. I would like to have an easy and memorable way of creating unique error numbers, across projects and across developers. The scheme I came up ...
0
votes
0answers
187 views

Rest Api Client response handler

I have two instances of Laravel: Rest Server API and Rest Client. Let's say I want to display list of positions on the front page. I'm making request to my Server API from my client controller: ...
1
vote
1answer
121 views

Zend 'Page Tile' view helper

I've created a ZF2 view helper PageTitle (extending Zend\View\Helper\AbstractHelper). As the name of the helper suggests , it is responsible for rendering the page title for each action view script. ...
1
vote
4answers
645 views

How to convince my company (operating in the financial sector) to switch from PHP to Java [closed]

My company is in the financial sector and it is using PHP as programming language. I am a PHP developer myself. I am leading a big project started from almost scratch. I can see how PHP is not the ...
2
votes
1answer
115 views

Is it bad practice to encapsulate a single operation in a class? [duplicate]

I recently had a back and forth over at StackOverflow about my answer to this question. The question was simple. The author wanted to transform a number into an abbreviated version that appended a K, ...
2
votes
6answers
806 views

Why is PHP's method of comparing different types bad?

I'm working on designing a new programming language and trying to decide how I will do variable comparisons. Along with many different types of languages, I've used PHP for years and personally had ...
1
vote
1answer
178 views

Is learning different programming languages from different categories good? [closed]

I have read some posts regarding learning different programming languages or not. Most of the answers indicate that learning more than one programming language increase our horizon as a programmer and ...
13
votes
4answers
834 views

What to do when your company doesn't encrypt passwords

Background I'm been contracted to help a company maintain their server. I work on some minor PHP projects but also look over performance issues and recently, scan logs for hackers. These guys have ...
2
votes
2answers
969 views

Front controller in PHP

When you are reading about web application development, "front controller" and "single point of entry" are frequent words you are confronted with. To my understanding, the point is to provide a single ...
2
votes
1answer
120 views

What design route should I take?

So I've taken on a project at work that I'm having a hard time attacking, and I'd love some feedback and suggestions. I work for an online retail store where we have an old, +7k-line script that we ...
1
vote
2answers
184 views

Is it bad practice to follow up a call to a terminating function with exit()?

I'm currently working on a php frontend. Specifically, the authentication process. I'll spare everyone the exact details of the decision tree, but it includes a lot of checks and about half of them ...
0
votes
1answer
113 views

Comment system sorting madness

I have a website in which I'm loading all of the users' comments by the number of likes they have. This has caused me some troubles. Let's say comment #1 has 5 likes, comment #2 has 2 likes, and the ...
1
vote
1answer
175 views

Handling array passed to object at creation

When creating my object I pass it an array of a row from my database. (everything in the array we will need, disregarding unnecessary elements at sql query level) When I need to access certain array ...
1
vote
1answer
229 views

How to discover a class in PHP dynamically much like a plug-in architecture

I'm encountering a common issue in PHP (and most other languages) at the moment, where systems I'm designing need to be updated in multiple places to add new features, whereas I would like to have a ...