Tagged Questions
Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.
0
votes
0answers
5 views
When to create upload image folder? @upload ? Or beforehand?
Ok,
Here's the deal.
Say, user0001 is uploading an image, do I create the folder when he creates said image?
Ie /images/00/01/user0001/ <-
Or, should I pre-populate the /images/ folder with the ...
-2
votes
0answers
70 views
What's the diffrence beetwen bulding software in Python compare to other languages [on hold]
I am coming for a PHP/Java background and i want to learn Python.
My question is not what's difference between PHP and Python. I want to know, how bulding software is different.
In PHP it's quite ...
-1
votes
0answers
30 views
PHP - Using $this when not in object context
When I try to execute this code from inherited class I got this error Using $this when not in object context
here my code
abstract class Connection {
private static $host;
private static ...
-2
votes
0answers
27 views
Differences between config formats? [on hold]
I'm trying to figure out what's the most appropriate configuration format for my web application, which is written in PHP.
The ones that I'm aware of:
json
very portable, but I can't add comments ...
-4
votes
0answers
30 views
Language for Web development on Embedded Systems [on hold]
I am planning to host a webserver on an embedded board like raspberry pi, radxa rock.
It should also contain a database like MySql.
My concern is that performance wise as well as development ...
-4
votes
0answers
27 views
PHP Internal DSL Examples [on hold]
In PHP, I want to see examples of useful/powerful internal DSL like code, tricks, or hacks. I will subsequently refer to these as DSLs.
A good answer will start with an inspiring code example of how ...
1
vote
0answers
40 views
Is this pattern of optional dependency injection sound?
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 ...
0
votes
0answers
22 views
Deleting all cached page of the site
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 ...
-2
votes
0answers
19 views
Beginning Creation of Mobile Workorder App [on hold]
I have the idea to build a mobile workorder app, that will basically allow selection from a customer list, be able to add items(and associate them with that customer), and automatically create a form ...
1
vote
0answers
48 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
73 views
Serving a file from a private directory [on hold]
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.
...
-7
votes
0answers
29 views
PHP - UPDATE (replace) e-mail adress [on hold]
I've got this problem:
When I try to update my EMAIL in database with this code:
<?php
$sql = mysqli_query($con,"SELECT * FROM users_en WHERE user_name = '" . $user_name . "'");
while ...
0
votes
2answers
40 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
95 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
78 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
2answers
87 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
95 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, ...
-3
votes
0answers
23 views
Php Form Data to Text Problem [closed]
Whenever i enter form data, the form action points to my php processing script but instead of writing it to a text file, it opens the code in the browser, what could be wrong?
My form
<form ...
0
votes
1answer
81 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
94 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 ...
-2
votes
0answers
43 views
Mysql PHP PDO Blank PAge when tried to set @varible [closed]
I got this php class from the internet which deal with mysql database:
<?php
class SSP {
static function data_output($columns, $data, $isJoin = false) {
$out = array();
for ...
1
vote
1answer
47 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
98 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
80 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
55 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
64 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 ...
1
vote
0answers
66 views
Successful use of Hack-PHP on large/enterprise projects [closed]
It's been about 5 years since first initial (and probably Facebook's internal) release of HipHop Virtual Machine and about a year since Hack Programming Language was considered stable.
Considering ...
-1
votes
1answer
44 views
Interchangeable array-object syntax [closed]
In PHP you can neither access an Object's properties with the array-syntax, nor array-values with the object-syntax. Is there any reason behind that? Why are not they interchangeable (Preferably like ...
-1
votes
0answers
24 views
What's a common approach to email notification digests (e.g. weekly summary of activity)
I'm trying to devise a process of sending daily, weekly and monthly emails. Here's what I'm thinking at this early stage:
A database table "notifications" with columns: id (PK), type and data (type ...
0
votes
1answer
46 views
How can I program the script on my server to the receive a cname pointed to it?
I am in the final stages of creating a mobile responsive customer relations management platform. Presently it is written in php as a stand-alone self-installing script.
I would like, however, to ...
0
votes
0answers
35 views
Login Tokens Remote DataServer for use in a Javascript/HTML-PHP environment
I've asked this question on stackoverflow, but i think this is a more appropriate place for it.
I'm creating an app for iOS, Android and the Web. I created a separate Restful Data Service that is ...
5
votes
1answer
111 views
How to use OO Design to Refactor a Library with Functions that are specific Product-aware
I have a class that acts as a library of functions for various products. To compute its data, the function currently needs to be aware of all product names. Depending on which product calls the ...
1
vote
0answers
41 views
Downloading a LinkedIn Users CV using the LinkedIn REST Profile API [migrated]
I am wondering if it is possible to make a call to the LinkedIn API using PHP that will allow me to GET the users uploaded CV.
Currently I'm working on some basic API calls that have enabled me to ...
0
votes
0answers
33 views
What could possibly be a Mysql database structure for an web app say like Flurry?
Simply say, I'm working on a web App say like Flurry (http://www.flurry.com/), that would communicate with a Smartphone App trough API.
Right now I'm designing the database structure, and I guess ...
1
vote
1answer
87 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
81 views
What should be the structure of a person to person store database?
I am going to create a person to person store with Laravel, a website where its users can share and sell their product or their mobile, TV, Computer, Shoes, Shirts, Books, Cars, Bags, Animal, etc.
I ...
2
votes
2answers
121 views
Can a class method be accessed both in an instance and statically?
I am relatively new to class design and I have a task that I'm not sure how best to complete, or whether my idea in general is a code smell.
I'm developing a RPG where people can own monsters, so ...
0
votes
0answers
3 views
cannot set project's JavaScript Build Path in PHP- eclipse [migrated]
Completely new to eclipse-PHP-javascript.
I have created a php project in eclipse and trying to set up the javascript Build Path after enabling javascript support for the project
The problem arises ...
2
votes
2answers
122 views
Should I use a large if statement inside a view or create a different view entirely?
I'm using the MVC architecture Laravel 4.2 to create a relatively complex web application. This application consists of a website which is very heavily based on whether an event has occurred or will ...
1
vote
1answer
50 views
Documentation of interfaces
I know how to document a function:
/**
* Prints a greet message to the web page
*/
function greet() {
echo "Hi!";
}
Or describe the usage of a variable:
/**
* @type string $name The user's ...
0
votes
0answers
42 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
0answers
31 views
How to pass user credentials to dovecot without storing it in the API
I have developed an interface to dovecot IMAP server using 'PHP IMAP' library. I wanted this interface to be standalone and thus it might have deployed outside the mail server. I used to test the code ...
2
votes
2answers
160 views
What is the best way to create REST API error response model and error codes system?
My REST implementation will return errors in JSON with next structure:
{
"http_response":400,
"dev_message":"There is a problem",
"message_for_user":"Bad request",
...
1
vote
2answers
195 views
Best approach to develop / distribute proprietary module
I've been brainstorming for a while regarding the best approach to distribute closed-source modules. I'd like to mention that I have found similar question(s) on SE sites but don't think this is ...
0
votes
0answers
46 views
Setting and getting values from a x-y graph
I have a bunch of x-y graphs given to me and I need to be able to transform them into some kind of data structure from which I will be able to get Y with X value.
The problem is, though that I have 4, ...
0
votes
1answer
29 views
Scoping template variables in “has-a” (compositional) relationships
I'm developing a new templating language for PHP, and one of the features is an object-oriented approach to nested child templates. For example, I can declare an object of type HtmlBuilder like this:
...
1
vote
1answer
226 views
Why does PHP allow sending mail from any address
I'm sorry if this has been asked but I'm not quite sure how to search for it. I'm having a bit of trouble understanding how mail() works in PHP. The way I see it, using that function, I can send ...
0
votes
1answer
64 views
Possible to refactor these methods that contain the same logical flow?
I have many methods in many repositories that have the same logical flow:
Retrieve value from Cache
Check value
If no value, fetch from Database
Update Cache
Return value
Is there a way to ...