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

learn more… | top users | synonyms

-1
votes
4answers
169 views

Best way to assure uniqueness in filename with php

I was wondering, without using any kind of user info (id, nickname, age, etc), what would be the best way to assure filename uniqueness using php in a large database with high traffic and most ...
1
vote
1answer
141 views

Get subset of associative array. Which of these is more readable? Is there another reason to use one over the other (or a different method)

If I have an array that has more info than I need and I want to pull out a subset of its name value pairs I have come up with 2 methods. Both rely on this: ...
0
votes
1answer
191 views

How would I structure my code into an MVC format?

I want to have the home page (root of the website), check if a cookie exists for a user being logged in, and then based off of that determining whether or not to load the sign up page (landing page) ...
9
votes
8answers
2k views

How should one debug a PHP web application securely without exposing secrets to competitors?

Recently I made a program. I forget to delete 2 line of codes. That mistake cost me $800 per day every day. I was programming with PHP. If a visitor uses proxy it redirect somewhere else. Using ...
3
votes
1answer
190 views

Should JavaScript and PHP objects be treated as different objects in an interaction diagram?

I'm drawing a communication diagram for an application where you can buy books. I'm using domain-driven design and have a 'shop' object, a 'cart' object, and a 'book' object. My first communication ...
0
votes
1answer
87 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 ...
0
votes
1answer
147 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 ...
3
votes
4answers
622 views

Which methods should be put in an interface and which in abstract classes?

I have seen many frameworks and modules and their standard they follow is like this UserInterface which have some predefined methods AbstractUserClass which implements userInterface Then ...
1
vote
1answer
235 views

Writing my own blog engine using PHP/JavaScript - am I doing it 'right'?

First, apologies in advance if this is in the wrong place - I wasn't sure if it should be here or in Code Review, but as I'm not actually asking for anyone to review my code . . . Here's my project: ...
2
votes
0answers
227 views

Which interface allows you to use a design pattern that is characteristically changed with the instantiation of objects?

I am doing a research on this and can't find my answer to this question: Which interface allows you to use a design pattern that is characteristically changed with the instantiation of objects? ...
1
vote
2answers
258 views

What design pattern matches this problem the closest?

I have two objects, one is a User object and the other is a Content object. The User object has properties like 'reads_articles' or 'reads_books'. The Content object has properties like 'is_article' ...
0
votes
1answer
336 views

Slower Ajax Response

Does putting the view logic inside the controller increase page load speed? Because I have a controller action calling a view which I am loading through ajax and I am getting a very slow response. Why ...
3
votes
2answers
213 views

What exactly happens on a LAMP machine when I request a php file?

I am a .NET developer who has recently started working in a LAMP environment. I know that if I go to www.somedomain.com/files/test.php, then (1) DNS resolves the URL to my server (2) my server handles ...
0
votes
2answers
199 views

Should I pass an object or values?

Let's say I have a model that has 'purchase' method. The purchase method should take care of purchasing a product. Signature of purchase public function purchase($token, Model_Member $member, ...
1
vote
2answers
143 views

How can I automate the process of code review

I have a team that works on multiple technologies. I want to know how can I automate the process of code review for .Net, .Net MVC, Python, PHP, Drupal and HTML5/CSS with JavaScript. I have read ...
3
votes
1answer
494 views

Pros and cons of namespaces vs include/require in PHP?

I recently started using namespaces in PHP. When I first saw them, I thought that their syntax was ugly and I'd never use them. However, I created an autoloader (spl_autoload_register) that makes it ...
0
votes
1answer
127 views

Python: Counter for Simultaneous calls of a PHP script?

I'm trying to create a queue processing script that's purpose is to find particular files and apply actions based on specific parameters, with the result being to call a PHP script that serves to ...
1
vote
4answers
253 views

What's the most readable way of echoing from PHP?

Should I use <?php if(!$user->is_logged_in()){ echo '<p id="login">Click <a href="login">here</a> to log in</p>'; } ?> or <?php ...
0
votes
3answers
165 views

Javascript Naming Convention [closed]

I've been using Javascript for quite a while, but I've always ignored the common naming conventions that I see online (camelCase). I know it all depends on the developer's preference, but why camel ...
1
vote
2answers
253 views

Is double password protection safe for admin authentication?

I was looking at some of my past codes, and I viewed one of my admin boards I've made. I had it setup so that the admin has to define/enter 2 passwords for his account. Is this really double-safe or ...
0
votes
1answer
119 views

Should the helper function in class be defined before the usage or after

I need to do the code review of fellow members. One of the member always defined the helper functions at the bottom and use them at top e,g class Sample { public function SendFile(){ file = ...
1
vote
1answer
178 views

Text conversion - Javascript before saving to db, or php when retrieving?

Long story short, I have a social networking site I wrote a while back as a "proof of concept" to myself that I had the skills to do it. I decided to revisit it, and "improve" a lot of the bad ...
4
votes
2answers
249 views

Is using static-typing the solution to domain-driven design and decreasing the number of errors?

We are using PHP (a dynamically-typed language) in our project. However, I have found my colleagues asking questions such as ...
0
votes
1answer
147 views

How exactly can I check for new rows in sql with ajax? [closed]

How do certain services, just like google plus and facebook, check for new content without reloading the page? Whenever you are on any of those websites a new notification of a post related content ...
-2
votes
1answer
146 views

Why use REST with PHP? [closed]

I am developing an app in Android, i need get information from a external database in mysql and i read about Rest.. REST is using HTTP verbs GET, POST, PUT, DELETE to respectively get, insert, ...
2
votes
2answers
147 views

HMVC and Database Connections

Whilst I have good experience with OOP, I'm fairly new to the concept of (H)MVC. I understand the basic concept of modular design that comes with HMVC, it's the great attraction of it. But one thing ...
1
vote
6answers
336 views

How do you handle multiple developer configuration in a project?

I've been thinking lately about how I handle config changes between multiple developers on a project. Specifically here about a Laravel project in PHP, but I guess this applies largely to all ...
8
votes
4answers
525 views

Is error suppressing bad practice?

On a SO question I asked here about some code I was unsure about, someone replied "BTW, horrible code there: it uses the error suppressing symbol (@) a lot." Is there a reason why this is bad ...
0
votes
2answers
84 views

How to manage potentially outdated data from WikiMedia API

I am writing a web application that pulls small parts of articles from Wikipedia and presents them to users. I do not wish to delete entries of the articles because I do not want to be sending a ...
3
votes
3answers
416 views

Alternative to Singleton when D.I. is not an option

I have been researching this extensively, and I am stuck. I am writing a Drupal module that uses a class that I have created. This class is a classic Singleton - it only needs to be instantiated once, ...
0
votes
4answers
1k views

Are frameworks used for “big” websites?

I'm kind of new to PHP. I can create basic sites with login/registration, etc., but I always struggle to build complex sites with lots of features, because eventually the code becomes messy and I just ...
2
votes
1answer
158 views

Technical reason of why you need to use Class::static_method() instead of Class->static_method() in PHP

I'd like to know if there's a technical reason of why PHP's designers decided to invoke a static method using Class::static_method() instead of Class->static_method() (like any other method). Does ...
0
votes
1answer
332 views

Basic OOP theory: misunderstanding surrounding database and user classes

New to OOP and trying to understand some basic fundamentals. Currently using PHP5 to build a basic web app. In using PHP's built in PDO as my database class and a separately created user class that ...
0
votes
1answer
200 views

PHP class data implementation

I'm studying OOP PHP and have watched two tutorials that implement user login\registration system as an example. But implementation varies. Which way will be more correct one to work with data such as ...
1
vote
2answers
73 views

Modules and themes [closed]

A module is a collection of files that together build a feature. A feature could be a login, viewing a User profile etc. A theme would contain template files and assets (img, css etc). The problem ...
1
vote
2answers
305 views

How to level up as a PHP developer [closed]

I've been doing PHP for 4 years now. 2 years at school and 2 years at work. But I feel like I'm stagnating. Here are some things that I currently know about PHP: Basics (variables, control ...
3
votes
3answers
650 views

Web application structure review

I'd like to have suggestions about the structure of my web application. What the app does: My app receives files from about 800 scanners around my country and the users see the scanned pages into ...
0
votes
2answers
238 views

PHP SplFixedArray How To Deal With billions of indexes?

I've built a flatfile db system that will work like mini-noSQL system and it split db to smaller files, and I did a SplFixedArray wrapper for it with a method for searching usage built on preg_grep. ...
1
vote
2answers
310 views

What's up with the Class::get(id) idiom in PHP

I am a new PHP developer (coming from .NET). The experienced php dev that I work with said that calling a static get method on a PHP class with an ID as a parameter is common in PHP. Is there a name ...
0
votes
2answers
216 views

How to explain to my manager the importance of separation of concerns?

I'm an extremely novice web programmer working at a 2 person shop building websites, and we're in the process of writing a simple website template system in PHP from scratch. My manager is entirely ...
1
vote
3answers
299 views

Arrays vs Objects in view template

I am wondering, in view templates, what would contribute to me choosing between using arrays or objects for getting things printed out in arrays {{$user->zip_code}} vs {{$user['zip_code']}} I'm ...
7
votes
4answers
284 views

Do $_POST, $_GET, etc violate the encapsulation principle?

Using globals makes your code hard to test thus more prone to bugs, not secure and unpredictable. That's why we pass the variables we want inside a function/object. So my question is simple: Do ...
1
vote
1answer
335 views

Liskov principle: violation by type-hinting

According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition. I know the example is pointless/nonsense, but when I last asked a question like ...
3
votes
1answer
148 views

Understanding exceptional cases

I've been studying the use of exceptions in various php projects (such as Doctrine and Zend Framework). Exceptions seem to be thrown when unordinary input/state occurs. A perfect example is Doctrine ...
0
votes
2answers
312 views

OOP PHP make separate classes or one

I'm studying OOP PHP and working on a small personal project but I have hard time grasping some concepts. Let's say I have a list of items, each item belongs to subcategory, and each subcategory ...
1
vote
2answers
212 views

Is curl something that's not expected to be installed on servers

Is curl something that's not expected to be installed on servers? I'm working for a small development shop and 99% of the problems that I'm having is regarding curl. Most of the projects that I'm ...
0
votes
1answer
131 views

PHP composer question

just getting started with composer and I have a couple of questions. When I use composer to add a dependency, the dependency gets added to my folder's Vendor directory. The newly added package not ...
-1
votes
1answer
435 views

Packaging PHP/Python files inside android .apk files?

I am developing an android app using HTML5. I want to make it work completely offline. I know that it is possible to package the .html, .css and .js files inside the .apk file itself in the ...
1
vote
2answers
330 views

Design pattern to handle queries using multiple models

I am presented with a dilemma while trying to re-designing the class structure for my PHP/MySQL application to make it more elegant and conform it to the SOLID principle. The problem goes like this: ...
3
votes
1answer
530 views

Reverse horizontal and vertical for a HTML table

There is a two-dimensional array describing a HTML table. Each element of the array consists of: the cell content rowspan colspan Every row of this two dimensional array corresponds to <td> ...