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

learn more… | top users | synonyms

3
votes
8answers
9k views

Is there a way to develop desktop software using PHP?

I have to develop a real estate marketing CRM software for my client - where the application is installed on desktop but can also be accessed from web. 2 reasons why they want the application to run ...
-1
votes
3answers
4k views

Can PHP be used for desktop application development?

I want to know whether it is possible to develop desktop applications using the PHP language. In my case, I have never developed one with it. If it possible, please give me referral link or detailed ...
0
votes
0answers
16 views

suggestions to help streamline html form creations

My colleagues and I are currently faced with an interesting problem. In our company, we have a website where employees can generate reports. Each reports have various parameters. For example, you have ...
0
votes
1answer
70 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, ...
0
votes
0answers
34 views

Best way to include an email system in an app? [on hold]

THE SITUATION: I need to implement an email system in my app. I need the user to be able to read, write, delete emails etc.. WHAT I HAVE DONE SO FAR: MANDRILL: I have actually finished it recently ...
2
votes
1answer
146 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 ...
27
votes
10answers
5k views

What is good (neat) architecture in programming a simple website, e.g. a contact book?

When I build a simple website, e.g. a contact book where I can add, delete and update contacts, I create an index.php file where a user, if he's not logged in, is requested to enter a password and if ...
1
vote
1answer
34 views

Symfony 2 Multi tenancy architecture, data loaded form front controller/kernel based on subdomain

Hello fellow programmers, (a bit of background)I'm building a Symfony 2 application for university Student accommodation, when our clients from the university side register with their details a ...
0
votes
1answer
71 views

Separating front end and back end using private api php

I am using php only for basic CRUD operations with MySQL. I want to create private API in php. From what I came to know , these are the steps for a developer local server to get data from remote ...
0
votes
0answers
31 views

Data Entry back-end Frameworks [on hold]

I have developed many CMS (WordPress) based websites, Most of them were E-Commerce sites, Restaurants or websites to list-down (sometimes with multiple categories and hierarchies) all the products of ...
1
vote
3answers
116 views

Auto-save user input - the smartest way?

I'm developing a social network website and I'm working with php/mysql/jquery and I want users to have the most user-friendly website experience. That's why I try to avoid a save (submit) button at ...
1
vote
1answer
162 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
465 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
2answers
139 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) { ...
-3
votes
0answers
48 views

Why can't I use the word 'header' in my PHP filenames? [closed]

Not really a coding problem, but when I saved my file as header.php, it didn't show up on my local server. I tried adding other files, they showed. I changed the name to headerTest.php, still didn't ...
-1
votes
0answers
50 views

Understanding multi-threadiing PHP (pthreads) [closed]

I am trying to understand multi-threading in PHP using pthreads via reading this article: https://gist.github.com/krakjoe/6437782 , but all the concepts/terms are going over my head. Such as mutex / ...
0
votes
2answers
57 views

What is the value of encoders with decoders currently present

Can you tell me the value of using PHP encoder (ioncube, phpshield) with currently present service like decry.pt (http://www.decry.pt/) that can easily decode source codes. I have tried decry.pt's ...
-3
votes
0answers
42 views

How can i loop through string of phone number and remove the leading zero and replace with country code? [closed]

Example: I want to replace each leading zero (0) of the phone numbers with "233"; $pn_box='08064342060,08052031697,08064342060'; Though I tried doing it this way but it converts only the first ...
2
votes
1answer
280 views

Change routing to comply with Law of Demeter

I have a Task, Owner and Plan. Charge values are kept in a plan, owner is on a particular plan and task knows its owner. A task needs to setup its charges based on the knowledge the owner has. Owner ...
0
votes
1answer
157 views

Laravel relationships and database schema

I am playing around with Laravel and came across something in the documentation for defining 1 to 1 relationships between tables that I would like to get feedback on. The example in the docs is ...
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
227 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
366 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
89 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 ...
2
votes
2answers
637 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 ...
1
vote
2answers
329 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 ...
20
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 ...
2
votes
2answers
357 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
74 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
53 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
101 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
1answer
2k 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 ...
0
votes
1answer
47 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
180 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
214 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 ...
0
votes
1answer
188 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
252 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
302 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
168 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
53 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
286 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
69 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
50 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 ...
1
vote
1answer
63 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 ...