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
77 views

Encapsulation: Separate functions for separate variables, or return a table? [PHP]

I have been making a website with PHP and I have a few classes, so far none of them really follow encapsulation rules of OOP. Lets say I have a user class like so: class User{ public $username; ...
0
votes
2answers
59 views

Storing and accessing settings from database query

I am trying to figure out the best way to accomplish this so feel free to criticize my thought process. My tool has different locales and each locale can have different settings for the tool. For ...
5
votes
2answers
206 views

How to handle a vendor who asks for the solution of an issue they could not solve

Being a small department of developers, it's not uncommon for us to outsource projects. We have a set of companies that we really like to work with, very reliable and good local people who appreciate ...
1
vote
1answer
162 views

API Key DDOS protection

Hi I just wanted some feedback on a DDOS preventing php script that I'm designing. It is quite simple and I wanted some feedback on whether you guys think it would be effective. I'm currently using ...
2
votes
2answers
207 views

Best pratice for return json in a REST application?

I'm starting now with REST (using Laravel 4.2) and Mobile (Android, iOS, SP, etc.) applications. Initially I'm checking if the request is ajax/json and then return a json response. But this ...
0
votes
0answers
116 views

When to use packages or Repositories in Laravel?

I'm a Laravel (PHP) developer, and new with DI, Packages (workbench) and Repositories (Pattern). I want to know about the best concept/methodology for a more flexible design; ie. the project can grow ...
0
votes
1answer
34 views

Roles configuration strategy

We're close to start new project using sf2, and, probably, FosUserBundle. Keeping that in mind - what's the best strategy to define roles? App will be used by multiple divisions inside our company ...
2
votes
3answers
108 views

Multiple many to many relations or one option table?

Let's say I have a database of persons who have some properties. For the sake of this problem let's say all of these properties relate as N-N. I can either create two tables for each property (one ...
0
votes
1answer
76 views

How can I configure updates in a CMS like WordPress?

I have a CMS built in core PHP. Till now, if a new version is released, it is downloaded to client machine in zipped form. And then client has to manually unzip the folder and copy that to required ...
0
votes
0answers
47 views

PHP: frequent file system write

I am building a game based on PHP and MySQL. Basically there is a player-vs-player mode but I figured I should add a player-vs-computer mode as well, since players may not be online at all times, ...
3
votes
2answers
132 views

I have a legacy project that I'm working on, how should I improve its structure?

I have a slightly old PHP project I'm working on for a client (I think it was started around 5 years ago), it makes extensive use of the outmoded mysql_query function, which is concerning not only ...
0
votes
1answer
223 views

Zend framework 2 authentication - only storing the user ID in session

I've just put together my first app using Zend_Authenticate. According to some tutorials I've read they store the user's "email" column. Is this recommended? I've read to store the ID only, then on ...
0
votes
0answers
28 views

Are Components ideal for packaging and reusing find() requests?

I find myself loading several models over and over again throughout my application. Instead of typing the code to load the model, run a find, would it be reasonable to put that code in a method and ...
0
votes
1answer
48 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 ...
0
votes
1answer
193 views

How can I fetch data from more than one web services simultaneously in PHP?

I have 3 web services that are providing me data for my hotel booking engine. It is taking too long if I run them sequentially. Therefore I wanted to run them using threads, but I am not sure if php ...
9
votes
6answers
2k views

Can someone help me understand MVC? [duplicate]

I've read a few articles on the MVC pattern and tried to understand what it exactly is. But till now, what I get is a plain diagram showing 3 modules of Model, View and Controller. Some say that it ...
-1
votes
1answer
55 views

Deleting dynamic elements from a database [closed]

I have a select dropdown, with '+' and '-' buttons that add and remove items before submission. I would like to be able to remove the elements with the '-' button after they have been added to the ...
2
votes
1answer
171 views

PHP Cache Strategy - Genius or Sheer Stupidity?

I have a shared hosting with limited capabilities. Memcache and mod_cache are not available to me. I would like to implement my own PHP caching method to cache the results of load-intensive SQL query. ...
0
votes
2answers
123 views

Is there a better way to load objects?

I have always kept the code to load an object within the object itself. That way no matter what method is creating the object, it always has access to the method to load the object. However this does ...
0
votes
0answers
75 views

Rendering STL file to STL viewer which is in new page

I've uploaded a STL file as an additional file for a product. And it gets downloaded in frontend as shown in screen shot. When I click on that link for STL Downloader, then that STL file will be ...
0
votes
1answer
60 views

Creating a voting platform for submissions during timeperiod

I have a site where stories are submitted at any time by users. The staff would like the ability to create a voting period at any time. For example, they can choose to open up voting from today until ...
1
vote
1answer
146 views

What is the simplest archive file format to aim for when writing collections of files?

I've created a PHP-based document management system and hosted it on my Raspberry Pi. I created a "backup" function that zips together all the documents, but it takes too long due to the hardware ...
3
votes
2answers
254 views

What's a good simple way to combat the n+1 problem?

I'm trying to better understand performance in PHP. One issue I'm thinking about is the n+1 problem. By n+1 I mean something like this: $posts = Posts::getPosts(); foreach($posts as $post) { ...
2
votes
2answers
271 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
votes
1answer
86 views

PHP4 constructor does not work with namespaces [closed]

Here's a scenario: whenever accessing class using namespaces in php, it doesn't launch the standard constructor, but only the 'magic' method. What's wrong here and what can be fixed? hierarchy ...
0
votes
1answer
84 views

Doctrine 2 and Concrete table inheritance

I use Doctrine 2 and I've read some articles on inheritance strategies' mapping with ORM. I've seen three main strategies : "Class table inheritance", "Concrete table inheritance" and "Single table ...
0
votes
1answer
77 views

How can I cancel all running mysql queries in a web application?

I am running a web application which has to scan (mysql query on a particular column) a huge MySQL table, which has over 100,000 records. The problem I find that when a user requests another page ...
1
vote
1answer
218 views

AJAX or web sockets for client-server communication?

I recently took a course on AngularJS, and quite frankly I loved the concepts of a website that fetches json to handle subsequent requests, however I still feel like Javascript is far too slow for ...
1
vote
2answers
136 views

How do two applications communicate? [closed]

Say I had a PHP page with a calculator interface, but I want to transfer the sum to Windows Calculator.exe and then get a reply from the application back to my PHP page, how do you go about doing ...
1
vote
1answer
178 views

Repository Pattern: Doctrine2 vs Microsoft Entity Framework?

I have been using Symfony2 with Doctrine2 for some years. I have recently started using Microsoft's Entity Framework with MVC5. From my Symfony2 experience I understand that a repository's job is only ...
1
vote
0answers
230 views

MVC content management framework with an admin panel

I've lately been developing my own MVC content management system using PHP and, at least in my mind, am a little stuck with the system design. I believe this would apply to building a content ...
1
vote
1answer
161 views

Should we live by using Suhosin with PHP?

A lot of my security experienced friends have told me that I need to code my web applications for working under the Suhosin PHP patch, Suhosin being "an advanced protection system for PHP ...
2
votes
1answer
123 views

Use and manage Front End Assets for Web

I am a beginner and am currently developing a kind of cms using PHP. The number of libraries that we can potentially use in the front end is large. I have a question about properly selecting, ...
-1
votes
1answer
87 views

Cloud Newbie … what should I know while creating my App [closed]

I never developed for the Cloud, and to tell you the truth I am not fully 100% sure of what Cloud is when coming down to servers and services. I am starting to develop an App where I will need to be ...
-1
votes
2answers
182 views

Is PHP the only popular language that mixes simple and associative arrays into a single type? [closed]

I'm doing a research on PHP and wondering if there any other commonly used programming langues that use an associative array for both simple indexed element storage and key-value functionality. Does ...
1
vote
1answer
164 views

Web Application: Combining View Layer Between PHP and Javascript-AJAX

I'm developing web application using PHP with CodeIgniter MVC framework with a huge real time client-side functionality needs. This is my first time to build large scale of client-side app. So I ...
0
votes
1answer
79 views

When to used static visibility? [duplicate]

I can't attain the primary used of Static Visibility. My question is why they used static method & properties in this code? class PassHash { // blowfish private static $algo = '$2a'; ...
-2
votes
4answers
240 views

What is the name of this design pattern? [closed]

I have been using this "design pattern" (may or may not be an "official" design pattern) for a while and I wanted to know if it had a name (so that I could name my classes after it). Example in PHP ...
0
votes
0answers
38 views

Laravel 4: Binding/linking two users together

I'm building a unittest system. At some point I want to bind two users together in order to make an assignment for those two. So when the admin chooses to link two students together the system should ...
0
votes
0answers
27 views

Writing Models in PyroCMS/Codeinighter Models

In Pyrocms there are Admin views and User views. Im developing a complex module where my model file is getting to be rather large. Should I be abstracting logic in my model files to also be User ...
0
votes
2answers
141 views

Flaws in my PHP development setup - sharing sources causing lags

I have following development setup for my PHP projects: Working station running on Windows 7 with PhpStorm IDE. GIT for version controlling. CentOS on virtual machine (VirtualBox) with Apache and ...
0
votes
2answers
146 views

Failed to allocate memory - What is it trying to say?

In my early days of programming I often used to get memory related fatal errors in the following format: Fatal error: Allowed memory size of <some big number> bytes exhausted (tried to ...
0
votes
1answer
497 views

Face Recognition(OpenCV) with MySQL and PHP

First of all I have asked this question on stackoverflow and got down vote for question being not belonging to the site. I am trying my luck se now(more suitable to se I guess) and I hope I will not ...
1
vote
1answer
211 views

Advice on refactoring PHP Project

I have a small SAS ERP that was written some years ago using PHP. At that time, it didn't use any framework, but the code isn't a mess. Nowadays, the project grows and I’m now working with 3 more ...
7
votes
1answer
138 views

Securely sending data from shared hosted PHP script to local MSSQL

I'm trying to add data from a webhook (from a web cart) to a local Microsoft SQL Server. It seems like the best route for me is to use a PHP script to listen for new data (POST as json), parse it, ...
2
votes
1answer
80 views

Do objects maintain identity under all non-cloning conditions in PHP?

PHP 5.5 I'm doing a bunch of passing around of objects with the assumption that they will all maintain their identities - that any changes made to their states from inside other objects' methods will ...
1
vote
1answer
30 views

Correct process for creating builds reliant on 3rd party packages

I work on a Symfony 2 codebase. We use a number of third-party packages (most are in the Symfony Standard Edition). We use composer for dependencies. We current have all of our third-party code ...
0
votes
0answers
119 views

Penny auction concept and how the timer works

I am creating a penny auction site using PHP yii framework. The main consideration of the system is to update the database records of all active auctions (max 15 auctions) with the current ticker ...
0
votes
1answer
154 views

Website File and Folder Structure

I am having a problem learning how proper website structure should be. And by that I mean how to code the pages and how folder structure should be. Currently I am navigating around my website using ...
0
votes
1answer
58 views

exception for string literal conventions

If I'm used to use ' for string literals in PHP, would it be better if I'll stick to it in any situation or can there be exceptions when it would increase readability? example: $foo = "bar'baz"; // ...