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

learn more… | top users | synonyms

-1
votes
1answer
18 views

Laravel - BLOB File Management System - Possible obstacles?

I'm working on this weird project where I need to upload huge files (500mb+) and store them in a postgresql table as a blob. Before you start telling me that storing files in the database is bad and ...
1
vote
1answer
53 views

Best way to centralise a php project (except bitbucket)

The structure is as follows: A: this is the live/production website B: this is the staging, which is a copy of live C: this is the testing environment for designers 2 developer and 2 designers. ...
-4
votes
0answers
18 views

Sync Microsoft dynamics(nav) with remote mysql

I want to sync microsoft dynamics CRM database to my remote mysql database using web service,I cant find detailed documentation to integrate dynamics with remote mysql so please give me any ...
-4
votes
0answers
37 views

What kind of PHP code is this? [on hold]

What kind of PHP is this? I have searched Google for hours looking for a clue to what type of php it is. Below is a sample snippet of the php code I need to find a tutorial for. I code in normal PHP ...
-3
votes
0answers
18 views

Help converting python::bitstream usage to PHP equivalent [on hold]

I need to read some data coming in from a client via a SOCKET using PHP. I found an example in python but I am not a python programmer. Here is the full python example code I am trying to covert. Note ...
0
votes
0answers
16 views

Prevent Timeout for large scripts without changing any System Settings

Current Option If I have a process that I know may take a while I have been chopping it up using ajax to do a part of the request then once the ajax is returned do the next part of the request. This ...
0
votes
1answer
47 views

Where to put utility classes in php mvc?

I'm working on my first MVC website, where can I put utility classes like Security and Date (my native date) classes, are they model too? App | |--- Model |--- Controller |--- View
1
vote
1answer
18 views

PHPUnit > Best approach to mock container objects? (e.g. $item->id)

I'm using PHPUnit test doubles to mock models, libraries etc. But when I want to return an array perhaps of container objects, how best to do so. Here is what I'm currently doing: /** * This is just ...
-2
votes
0answers
36 views

PHP only showing records by id? [on hold]

I am having trouble with this PHP code and I am not sure how to title it! I have a car showcase and I am wanting the Database to display the cars depending on their ID e.g 1 Ferrari Enzo, 2 Porsche ...
1
vote
1answer
35 views

PHP MVC Model with a method to fetch all of the model from database

I have a crazy question, consider I'm developing a blog website, There is two model named Post and Comment, now I wanna add a method to fetch all comments from database, which model should I choose to ...
0
votes
0answers
13 views

How to push data from one page to another [PHP] [migrated]

I'm using sockets.io, express and php and I was wondering if it is possible to push something of a page (that only a specific user can see at the time) to another page other can see. For example, if ...
1
vote
1answer
66 views

Need to store Multiple Images (path) into MySQL after upload [duplicate]

I am trying to build my own little eCommerce CMS, and i want the expert opinion on how to handle multiple uploaded files (images). For Example: A user adds a new item, fills the necessary form data ...
0
votes
2answers
142 views
+100

Storing and retrieving simple data within a framework

I'm determined to get a decent answer to this, because while I have my own approach (constants) I'm not convinced I'm doing it as efficiently as I could be. So I'm editing the entire question, to ...
0
votes
0answers
27 views

Preserving Pre-formatted Multi-Line Strings in Node.js Scripts

There is a lot I don't like about PHP, but one thing I love is multi-line strings: $query = <<<EOT select field1 ,field2 ,field3 from tableName where field1 = 123 EOT; ...
0
votes
1answer
70 views

Database object mapping, good practices [closed]

I think I've understood the basic idea behind object mapping but there is one gap in my knowledge base that I hope to fill now. First let me tell you what I understand out of the whole thing. I have ...
2
votes
0answers
64 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 ...
0
votes
1answer
55 views

How to efficiently determine when changes occur in event lists

We have a system that stores event information. There is a primary list of events as well as a secondary list, these may overlap. Secondary lists are combined with the primary based on 3 main rules. ...
0
votes
2answers
56 views

PHP extended class method requires same signature including object class requirement? [duplicate]

Not sure exactly how to phrase the question succinctly for the title. I have a collection class that extends another collection class. The parent collection-class has a method addMember(someClass ...
0
votes
0answers
48 views

How to dynamically print a URL as a QR Code using PHP (Drupal Views)

I'm working a small home project, and I wish to dynamically produce a QR code on a content Node (I'm using the Drupal 7.3x CMS framework and specially the Barcode Module). I've not had much success in ...
0
votes
1answer
75 views

How to appropriately structure a script used in an AJAX call?

When I first learned AJAX, I was also teaching myself the languages of PHP, JavaScript, SQL, HTML, and CSS. I followed my coworkers existing web apps as examples of how to write my own web ...
0
votes
1answer
54 views

How to handle coding errors in my PHP AJAX code?

How do I handle coding errors in my PHP which has no GUI, only an API? I am concerned that I might never know that there are any. Note that only I will develop the client side. This is not a public ...
-1
votes
0answers
20 views

Data Type of file_get_contents of php in java [migrated]

I am trying to upload an image to the database with blob datatype. I use web-service method addProfilePic that store the blob data to the database with my Codeigniter project. I retrieve the image ...
0
votes
0answers
22 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
2answers
35 views

Best Way To Store Images For Mobile Synchronization

The scenario is, I have a Web Dashboard (Developed using PHP + MySQL) and have Android and iOS Apps synchronizing data from the Web Dashboard (only one way i.e. Dashboard to Mobile Apps) Now the ...
0
votes
1answer
66 views

Is this a good service locator, and is this service locator pattern(?) OK?

I'm working in Zend framework 1 and was using Zend_Registry to store objects so that I could replace them in my controllers while unit testing: $auth = Zend_Registry::get('Auth'); // set in ...
0
votes
0answers
46 views

PHP mail templates

I'm working on a webshop (used to be for just one product, expanding it to multiple products and multiple shops hooked up to one backoffice, can't use PrestaShop because of compatibility). We send 3 ...
3
votes
1answer
202 views

How to hide a honeypot ( excluding external CSS and JS )

I am adding spam protection to my personal php framework and I think honeypots are a great way to block spam. Unfortunately they weren't invented yesterday and probably most bots do fetch CSS and can ...
2
votes
1answer
165 views

An embedded C developer wishing to interface some code with a web page

Okay, so as the title says, I'm an embedded C/C++ developer. Right now, I'm working on a project that involves a client/server C application. The server side of the application is running on ...
0
votes
1answer
93 views

Protected properties vs protected getters

If I have an abstract Animal class with a $name property and constructor like this: abstract class Animal { protected $name; public function __construct($name) { $this->name = $name; ...
1
vote
1answer
84 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
1answer
41 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 ...
-1
votes
0answers
10 views

MySQL Query - how to keep normal users from seeing staff posts? [migrated]

On my forum, I'm having an issue where non-staff members can view staff related posts that are otherwise hidden to normal users. Upon investigating I've discovered that staff related topics do not ...
1
vote
0answers
64 views

Is this pattern of optional dependency injection sound? [duplicate]

A lot of the time when working on legacy code bases, I find it hard to move manually created dependencies to the constructor parameters, because of a variety of reasons. Sometimes it's because the ...
2
votes
0answers
119 views

Deleting all cached page of the site [migrated]

Scenario Mobile and desktop version. I'm developing a website with a desktop and a mobile version: users can choose to switch version if they want to: javascript will save a cookie telling the ...
1
vote
1answer
99 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 ...
-2
votes
0answers
29 views

Not sure where to put the where clause In codeigniter [migrated]

I have been looking over the active records guide from codeigniters site and I am trying to figure where to put the where clause, in the model or controller? I think it goes in the model, but not sure ...
0
votes
2answers
80 views

Serving a file from a private directory [closed]

I have a PDF that needs to be accessible for multiple unrelated areas across a website. I don't want to reveal anything about where the file is downloaded from and I want to only upload the file once. ...
0
votes
2answers
45 views

What pattern do I use and how do I implement it for one method that will be handled multiple ways

My scenario: I am creating an application that will allow me to create a mapping of redirect url's that will point from the request url (the url in the old ecommerce solution) to the target url. There ...
0
votes
1answer
101 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 ...
2
votes
1answer
87 views

How to add permissions checks 'after the fact'

I have a great number of PHP classes which perform the business logic of my application, e.g. class FileMaker{ public function makeFile(){ //some code here to make a file } } Now I need to ...
-3
votes
0answers
18 views

PHP Help with Call to a member function add() on a non-object [migrated]

Question: What is the problem that I apparently cannot pass an object through to this method? Code: http://pastebin.com/fUbJdgXk Issue: Line 22 $this->business->add($specrep); returns Call to a ...
1
vote
3answers
137 views

Controller in MVC

Alright so it is an essential part of OOP that one class should only do one thing, and it makes sense. In practice I've seen that classes which don't obey this rule get thick and cluttered. So I was ...
1
vote
1answer
111 views

Does ORM at any point become a “requirement” for RESTful API?

I've started building a RESTful API in PHP's Slim framework. The framework appealed to me because of its light-weight design and routing features. I am using PostgreSQL for the database. However, ...
0
votes
1answer
85 views

Is this the template method pattern?

Could someone tell me whether the following is A) a good solution to the problem of repeating code and B) an example of the template method? Let's say I have one table, named VEHICLES, which I use to ...
0
votes
0answers
109 views

Is this a good implementation of the builder pattern?

I'm trying to design an SQL builder in PHP. I'm trying to make it so that the system could work with different database systems (e.g. Oracle, MySQL, MSSQL). Here's what I've got so far. First, I have ...
1
vote
1answer
61 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 ...
3
votes
1answer
102 views

Creating variables in methods/functions

In how far do we create variables in our methods or functions? Do we only create one when we're using the result of the variable more then one time like this? function someFunction(SomeClass ...
2
votes
1answer
90 views

How to design database tables for a Factory class?

How can I design database table structure for a class that varies in its core parameters, when it is created by a factory method? I have a Factory like this: class ProductFactory { public ...
1
vote
1answer
68 views

PHP MVC Display many records - model logic

I bet this question has been asked already but I can't form my thought as you can see from the title, so I couldn't find anything. I am working with MVC for quite some time now and I'm pretty happy to ...
0
votes
1answer
66 views

Condition before statement or statement in condition

I've come across this problem a few times: Is there any "programming rule" for checking for an condition (error checking for example) before you want to do execute code, or only execute the code when ...