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

learn more… | top users | synonyms

0
votes
2answers
9k views

Simple real-world PHP OOP example?

I'm trying to learn PHP OOP, but when I've followed tutorials, all the examples seem to involve things like: class Human { $_sex; public function setSex($sex) { $this->_sex = ...
2
votes
2answers
195 views

Lesser of two evils regarding return types

I'm implementing a system in PHP where values are represented with objects that implement an Amount interface. I'm building two different implementations of this interface, one using a simple integer ...
1
vote
1answer
348 views

MVC URL structure with URI parameters

When creating routes for your MVC web application I have seen two possible ways to pass variables to a controller method: With the first approach the variable is passed to a parameter of the ...
2
votes
1answer
87 views

Recommend an approach to decouple Product and Access code constructs, in order to simplify Product testing

I have some code that tightly couples Product specific code and Product-Access code. I am not sure how to untangle it. So for example, for testing Product, I have to mock up Access objects. And ...
-4
votes
0answers
21 views

Enable php-phantomjs to use disk caching? [on hold]

Phantomjs has a disk-cache option that works when running via command line, but when I use php-phantomjs it seems that no disk caching is created, although I'm setting that option. Can it be because ...
-6
votes
0answers
23 views

How to make Online shop with quest/mission? [on hold]

Sometimes I Bored, What can i do?,but Reality I just a beginner programer ~ Now I want make new conception online shop with quest/mission like a game online can master help me? :(
-2
votes
0answers
26 views

Unicode Support and future versions of PHP [on hold]

PHP 6 was planed to enhance Unicode Support. PHP 7 roadmap does not address this as well. What will be happen for PHP regarding multilingual support?
2
votes
2answers
619 views

Repository pattern implementation that knows nothing about the database table and column names

I've seen around the Internet and Github, implementations for the design pattern Repository that knows about database table and column names. I was think, if I want to work with the database as a ...
-5
votes
0answers
21 views

Generate a dynamic dropdown and embed a php code [on hold]

I want to create a drop down dynamically and display a data in to drop down from database. and when click on product from drop down I want show two textbox.
1
vote
2answers
321 views

Is this a race condition?

I have a friend arguing this is a race condition, but I'm struggling to understand how. This is for a web application using PHP and MySQL where users can login and create tickets, these tickets have ...
19
votes
5answers
8k views

What best practices should be employed in a PHP login script?

I am wanting to re-write my login scripts for clients websites to make them more secure. I want to know what best practices I can implement into this. Password protected control panels are in their ...
-2
votes
0answers
21 views

Restricting file types when uploading to my server [migrated]

i'm currently working on a project for an IT class i'm teaching, so i've set up this page on my website where students can upload html files, so they can see what the final result is. How exactly ...
-5
votes
0answers
41 views

How to open Modal box after saving data to database and show result [on hold]

I need to open modal box for showing the error message or success result after uploading data from CSV in mysql . Please suggest me how can I made it possible ? $res = true //if no error $res = ...
2
votes
2answers
344 views

MVC with Post/Redirect/Get

I have a question in mind for the MVC pattern for a long time now. When using the Post/Redirect/Get principle then it doesn't make sense to use ONE model in the sense of MVC, right? Why should I ...
0
votes
1answer
62 views

PHP MVC how to access current user?

What is the best way to tell if a user is already logged in when accessing the page? I have seen many people talk about a Recognition service that will validate a user trying to login, but what about ...
1
vote
1answer
46 views

Generic PHP web interface for handling concurrent updates optimistically

I'm looking in to writing a new PHP based CMS which handles concurrent edits optimistically like source version control rather than pessimistic locking like Wordpress. I want to be able to write some ...
1
vote
1answer
99 views

DI container with multiple instances of same object

I'm looking for idea to make a DI container that can store multiple instances of the same object. Usually, a DI container should store either a single instance of the object, or create new object each ...
0
votes
0answers
29 views

How to approach building an achievements system using redis? [closed]

We're building an achievements system based on the interactions a user can do on the website such as answering, following, agreeing with an answer etc... by achievement I mean answering 50 questions ...
0
votes
1answer
1k 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 ...
-7
votes
0answers
53 views

Why Frameworks are overrated over Composer? [closed]

Where-ever I see a job description, it at least asks for experience in one of the PHP frameworks. I mean like, why do employers emphasise possessing experience in one of the popular PHP frameworks? ...
-8
votes
0answers
31 views

Unable to emails to multiple recipients using phpMailer, even after using explode function [closed]

I have been trying to send email to multiple recipients using phpMailer, also i added explode but it didn't go through. <?php include 'connect.php'; $emailID = $_POST['email']; $sql = ' ...
0
votes
1answer
39 views

PHP Multi-Page / Session Question

I created index.php that basically looks up all the individual php files (articles) in a few subfolders and prints them out. Since the quantity of articles is over 30 and growing, I implemented a ...
1
vote
1answer
177 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 ...
11
votes
2answers
1k views

Is an NPath complexity of over sixteen octillion realistic? Or have I broken the tool?

I have just measured a large chunk of PHP code (1153 lines) using PHPMD (http://phpmd.org/) and it tells me the code has an NPath complexity of 16244818757303403077832757824. That looks like a ...
1
vote
1answer
207 views

Design pattern where decorated object may ask for things like “status updates” from the decorator to perform it's role?

Here's an situation that has haunted one of my open-source projects for quite some time. Imagine if you could represent every front-end input form with a single backend object? An object that ...
-3
votes
0answers
25 views

PHP Company Web App - updating database classes [closed]

I've recently joined a small company as a junior web developer that specialises in managing customer orders for small businesses in the catering industry. The company has developed an app in PHP that ...
0
votes
1answer
186 views

Should I use session or cache to keep the time it last polled when polling to server at intervals?

I'm building a web chat app using session to keep the time the app last polled so that the server can determine whether messages exist between the current polling time and last polling time. It works ...
1
vote
5answers
250 views

Are mocks in unit tests dangerous in dynamic languages?

I've started relying heavily on a mocking framework in php for my unit tests. My concern is that with a dynamic language, there is no way of enforcing a return type. When mocking, you have to ensure ...
0
votes
3answers
368 views

How do I handle 3rd party search result data (via cache)

I have a search function on my site and it is taking data from 6 different 3rd party resources. The problem is, it takes too long requesting the data over and over again on the results page. I've ...
1
vote
1answer
281 views

mySQL / PHP design pattern - one function multiple queries

So here's the gist of it. I'm looking for a design pattern where I can have one function, say queryHandler that gets the query and the parameters from a number of different functions and returns the ...
0
votes
0answers
66 views

SQL Query based on URL [migrated]

I have a sql query which brings back information based on the Sessions Cookie. I want to make a link to a users profile and have a url like account.php?id=Danny Then i want to run a sql query but ...
0
votes
1answer
157 views

Like structure table with Laravel and showing the most popular content at top

I am using Laravel to creating a website, my users can post questions and other users can write their comments under the post, each comment have Up vote and Down vote, and users can voting for ...
0
votes
0answers
9 views

Unable to insert datetime value into a MySQL table using PHP [migrated]

I'm trying to run the following code in PHP: <?php require_once 'Admin/Connector.php'; $name = 'A Schandillia'; $number = '12345678910'; $latitude = '73.897687'; $longitude = '11.958271'; $sql = ...
0
votes
1answer
52 views

Development and testing PHP script that gets variables from external server

I have a web app that sends users to an offsite payment server to complete a transaction, and I'm working on the PHP page that users are returned to upon completion of the transaction. The script uses ...
1
vote
1answer
279 views

How to avoid big class complexity while keeping encapsulation?

I'm developing a PHP library to work with big numbers (at this moment only with a "Decimal" class, but I want to add new classes, to handle Integers, Rationals, and Complex numbers). In any case, the ...
1
vote
2answers
276 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. ...
1
vote
1answer
65 views

How bad is it that my index.php in a Zend Framework MVC application mixes definitions and side effects?

I'm introducing some more coding quality standards and checks via a new project - in particular, the PHP-FIG recommendations. This project using Zend Framework 2, and I have a fairly simple entry ...
0
votes
1answer
45 views

PHP and Subversion workflow [duplicate]

I'm working on a project in a small team at the moment working on a webapp. We originally had 3 on the team with a lead dev and now we've grown to 7 and a lead dev. At the moment our workflow is ...
0
votes
1answer
59 views

Architecture: Validate polymorphic votes - Controller or Model?

I have a question because I don't want to do something wrong. I have a polymorphic relation called votes. Well, I want to save votes but I need to validate if a user already has voted. But even if, ...
2
votes
1answer
119 views

Scheme/Design Pattern for allowing a certain outside class to set properties

I came up with a solution (in PHP) to a problem and am wondering if it is a named Design Pattern, and if it is good practice. I have a collection class and an item class. The collection class is the ...
1
vote
1answer
56 views

MVC, pagination, and massive search criteria

I am currently working on a project that has a fairly large search form - the form is 30 or fields or more. Now I can of course map this out for routing by having my application pull the parameters ...
0
votes
0answers
42 views

Class Interfaces with Multiple Classes and Dependency Injection

NOTE ON QUESTION TITLE: I did not really even know how to phrase the title so if someone can edit and make it more articulate I would really appreciate it. QUESTION: Basically, what I'm trying to do ...
0
votes
1answer
80 views

PHP - How to structure this application

Sorry if the title is leading.. I'm looking for advice for the following system I am implementing: The system is to provide quotes for customers, this is then exported to PDF and emailed to the ...
4
votes
1answer
104 views

Social network notification system

Background I am working on an app for a client that includes some social networking features. I was originally developing the mobile front-end, but circumstances have left me in charge of developing ...
-2
votes
0answers
27 views

PHP Static and Normal Functions Calling [migrated]

Can someone explain how these line of code are working class DemoStatic { function normalFunction() { echo "This is the normal function"; } static function staticFunction() { echo "This ...
3
votes
2answers
1k views

Is doctrine 2 fast enough? [closed]

I need to build a social network that is expecting very high traffic, 10k - 50k + registrations in a day, not even including visitors, pageviews, image uploads, etc..., a lot of database activity. We ...
1
vote
1answer
140 views

Is there a way to document required properties in traits (PHP)?

I'm fairly new to using traits in PHP and am wondering if there is a way to ensure that a class including a trait has particular properties. I know that you can use something like the following to ...
0
votes
1answer
443 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 ...
0
votes
1answer
103 views

Cleanly using PHP Iterator class in Loops - calling first element

I have implemented the Iterator class in PHP and built the follow mandatory methods as follows class I implements Iterator { private $a = []; function __construct(array $a) { ...
1
vote
0answers
185 views

Android, PHP session and JSON object retrieval

I am working on an app in android studio.. it currently has a login and registration system that are linked to a database and both work perfectly. I am now trying to carry over the user id value ...