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

learn more… | top users | synonyms

0
votes
3answers
178 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
358 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
793 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
80 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
198 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 ...
2
votes
1answer
172 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
418 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
169 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
95 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
625 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
112 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
784 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
174 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
823 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
721 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
170 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
111 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
174 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
220 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 ...
1
vote
2answers
313 views

Interface Segregation Principle - type hinting multiple interfaces

The question is about typehinting of the role interfaces. The code example has two DataMappers which typehint the interface they need in the constructor, FooDataMapper type hints the Preparable ...
1
vote
1answer
152 views

How to refresh/keep up to date content in the browser without overloading the server

I am not very educated on this topic of programming so I am seeking any advice/knowledge. I am coding a web app in PHP, and this particular task requires updating the display after the server has new ...
0
votes
1answer
727 views

Reporting Solution in PHP / CodeIgniter - Server side logic vs client side

I'm building a report for an end user. They would like to see a list of all widgets... but then also like to see widgets with missing attributes, like missing names, or missing size. So i was ...
2
votes
2answers
187 views

Achieving multiple tasks within one loop

With relation to what's considered good OOP engineering principles, SOLID, DRY, KISS etc I am wondering whether to complete multiple tasks within one loop when easily done. The problem is that this ...
0
votes
2answers
112 views

PHP passing parameters to a function [closed]

I want to pass a parameter to a function as below for clarity. It doesn't give any error. But is this a bad practice. Do I have to avoid this. test('','','',$d='text',''); function test($a, $b, $c, ...
4
votes
5answers
2k views

Programming PHP without MVC, classes or framework: rewrite or continue on new features?

I have been programming for several years now, and back then (learning PHP) I've didn't learn to program using classes, MVC-logic or using any frameworks. I found my self solving my problems very well ...
0
votes
2answers
311 views

In PHP, should I delete objects immediately after use?

I've read in PHP Advanced and Object Oriented Programming by Larry Ullman that it is good programming practice to delete object immediately after use but reason is given nowhere. I am a student web ...
2
votes
3answers
577 views

Should I convert the whole project to UTF-8?

I am working on a highly customized shop software, based on a open-source one, written in PHP and usual web techniques (CSS, HTML, JS). I did a lot of customization in the past months/years and ...
-1
votes
4answers
211 views

Best way to assure uniqueness in filename with php

I was wondering, without using any kind of user info (id, nickname, age, etc), what would be the best way to assure filename uniqueness using php in a large database with high traffic and most ...
1
vote
1answer
295 views

Get subset of associative array. Which of these is more readable? Is there another reason to use one over the other (or a different method)

If I have an array that has more info than I need and I want to pull out a subset of its name value pairs I have come up with 2 methods. Both rely on this: ...
0
votes
1answer
245 views

How would I structure my code into an MVC format?

I want to have the home page (root of the website), check if a cookie exists for a user being logged in, and then based off of that determining whether or not to load the sign up page (landing page) ...
10
votes
8answers
3k views

How should one debug a PHP web application securely without exposing secrets to competitors?

Recently I made a program. I forget to delete 2 line of codes. That mistake cost me $800 per day every day. I was programming with PHP. If a visitor uses proxy it redirect somewhere else. Using ...
3
votes
1answer
252 views

Should JavaScript and PHP objects be treated as different objects in an interaction diagram?

I'm drawing a communication diagram for an application where you can buy books. I'm using domain-driven design and have a 'shop' object, a 'cart' object, and a 'book' object. My first communication ...
0
votes
1answer
133 views

PHP - PSR 0 - Configuration Constants

This question is about PSR-0 autoloaded libraries and the way main configuration constants should be declared and used. From your point of view (lib/framework developer), where/how should be declared ...
0
votes
1answer
256 views

How should dependencies be managed across a modular application?

Let's say that we have a structure like this: Application -- Modules --Module1 -- Controller -- PublicHelper --Module2 -- Controller ...
4
votes
4answers
754 views

Which methods should be put in an interface and which in abstract classes?

I have seen many frameworks and modules and their standard they follow is like this UserInterface which have some predefined methods AbstractUserClass which implements userInterface Then ...
1
vote
1answer
296 views

Writing my own blog engine using PHP/JavaScript - am I doing it 'right'?

First, apologies in advance if this is in the wrong place - I wasn't sure if it should be here or in Code Review, but as I'm not actually asking for anyone to review my code . . . Here's my project: ...
0
votes
0answers
266 views

Which interface allows you to use a design pattern that is characteristically changed with the instantiation of objects?

I am doing a research on this and can't find my answer to this question: Which interface allows you to use a design pattern that is characteristically changed with the instantiation of objects? ...
1
vote
2answers
264 views

What design pattern matches this problem the closest?

I have two objects, one is a User object and the other is a Content object. The User object has properties like 'reads_articles' or 'reads_books'. The Content object has properties like 'is_article' ...
0
votes
1answer
611 views

Slower Ajax Response

Does putting the view logic inside the controller increase page load speed? Because I have a controller action calling a view which I am loading through ajax and I am getting a very slow response. Why ...
3
votes
2answers
223 views

What exactly happens on a LAMP machine when I request a php file?

I am a .NET developer who has recently started working in a LAMP environment. I know that if I go to www.somedomain.com/files/test.php, then (1) DNS resolves the URL to my server (2) my server handles ...
0
votes
2answers
203 views

Should I pass an object or values?

Let's say I have a model that has 'purchase' method. The purchase method should take care of purchasing a product. Signature of purchase public function purchase($token, Model_Member $member, ...
1
vote
2answers
162 views

How can I automate the process of code review

I have a team that works on multiple technologies. I want to know how can I automate the process of code review for .Net, .Net MVC, Python, PHP, Drupal and HTML5/CSS with JavaScript. I have read ...
4
votes
1answer
2k views

Pros and cons of namespaces vs include/require in PHP?

I recently started using namespaces in PHP. When I first saw them, I thought that their syntax was ugly and I'd never use them. However, I created an autoloader (spl_autoload_register) that makes it ...
0
votes
1answer
140 views

Python: Counter for Simultaneous calls of a PHP script?

I'm trying to create a queue processing script that's purpose is to find particular files and apply actions based on specific parameters, with the result being to call a PHP script that serves to ...
1
vote
4answers
262 views

What's the most readable way of echoing from PHP?

Should I use <?php if(!$user->is_logged_in()){ echo '<p id="login">Click <a href="login">here</a> to log in</p>'; } ?> or <?php ...
0
votes
3answers
177 views

Javascript Naming Convention [closed]

I've been using Javascript for quite a while, but I've always ignored the common naming conventions that I see online (camelCase). I know it all depends on the developer's preference, but why camel ...
1
vote
2answers
272 views

Is double password protection safe for admin authentication?

I was looking at some of my past codes, and I viewed one of my admin boards I've made. I had it setup so that the admin has to define/enter 2 passwords for his account. Is this really double-safe or ...
0
votes
1answer
275 views

Should the helper function in class be defined before the usage or after

I need to do the code review of fellow members. One of the member always defined the helper functions at the bottom and use them at top e,g class Sample { public function SendFile(){ file = ...