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

learn more… | top users | synonyms

1
vote
1answer
20 views

Laravel 5.2 - Better to create a Service Provider or Helper class or otherwise?

So I have created an API endpoint (obviously not restful) that generates xml and returns the file path of the files. Its obviously more complicated but that is the gist. My issues is this. Inside my ...
7
votes
6answers
2k views

What is an effective way to familiarize yourself with a new application in a new language (and still look productive at a new job)?

I started a new job working on an application I'm vaguely familiar with, and it's in Perl! I come from a PHP and Java background, so while I understand the basics, there are lot of nuances in Perl ...
0
votes
1answer
237 views

How to secure my authentication code?

I'm working a PHP project where I need to authenticate users to a portal. Just wanted to get your opinion on the code, statistics of the website show some strange behaviour with the login form. ...
-8
votes
0answers
40 views

I need help getting the php code [on hold]

I would like to create a web based form that the data gets collected in a mysql table, I have the html file and mysql file. I do not know how to make it a php to connect to mysql. The files are ...
-4
votes
0answers
56 views

OOP PHP hands on guide [on hold]

This is not a duplicate question. Most book recommendations are about the language and concepts. I don't need a book that goes deep into the OOP concepts and language constructs. I'm a beginner in ...
0
votes
0answers
37 views

Using numeric arrays or associative arrays search and retrieve data ? [ file paths of a page]

I am building on a CMS where dependencies and files needed for a page get stored in the database. Because this can be very dynamic, I serialize these paths into one Database field into my pages table. ...
-5
votes
0answers
28 views

Help Query eats my server [on hold]

Hi I am facing the problem in my query and its eating a lot on my server whenever a shortened link is visited,Its a url shortener like adfly. select *, count(distinct views.views_id) as ViewCount ...
-3
votes
0answers
44 views

PHP IDE Support, sublime text vs vscode vs eclipse, how to jump to definition? [on hold]

I am usually using Eclipse with PDT for my PHP projects. Eclipse is quite Ok, but it's very heavy and slow. I decided to try SublimeText3 and VSCode (which is really nice). Both have some PHP support ...
-6
votes
0answers
46 views

How the node js can be used in yii? [on hold]

I just want to use node js in my yii project. Is there anyone who can guide me with steps to use yii with node js? It would be better to explain it by taking example. Thanks, Gaurav
-1
votes
2answers
206 views

Registration form with email verification

Can someone point me in the right direction: I need to make a website with a registration form, to create accounts with e-mail verification, to write the forms content in a database table or something ...
-4
votes
0answers
56 views

Question for PHP developers [on hold]

I am taking a psd design and converting it to a responsive bootstrap design. Dumb question though, I will convert these to HTML pages, is there anything I need to do to prepare them for PHP or ...
0
votes
0answers
25 views

Resolve route before invoking middleware chain

Say I have a HTTP middleware chain that handles all incoming requests. Where should the incoming request be resolved into an appropriate route? I have thought about doing so before the middleware is ...
7
votes
5answers
15k views

How to structure template system using plain PHP?

I was reading this question over on stackoverflow: http://stackoverflow.com/questions/104516/calling-php-functions-within-heredoc-strings and the accepted answer says to do plain PHP templates like ...
0
votes
1answer
27 views

Serialized object data for template settings - best design? [on hold]

I am currently working on a CMS that uses HTML templates with PHP variables in it. A few of these stored variables: background_color font_size image_url Etc.. I am currently categorizing these ...
2
votes
1answer
80 views

Is there a good way to use the front controller pattern for command line applications?

I am a PHP developer and I used to build web applications with one PHP file per page for a very long time. This resulted in duplicated logic and messy code (even though I didn't know it at the time). ...
11
votes
2answers
1k views

How to go about testing un-injectable code?

So I have the following piece of code in use all over my system. We're currently writing unit tests retrospectively (better late than never was my argument), but I don't see how this would be ...
3
votes
1answer
429 views

How to bypass Oauth2 authentication when the client and resource owner is the same entity?

We are currently working on using an API provided by Mercado Libre which is a maket place for selling various goods. Their APIs use OAuth 2.0 for authentication. The problem is that OAuth 2.0 as ...
13
votes
8answers
21k views

Is there any design pattern except MVC for web?

I want to know are there any design patterns for web besides MVC? I know there are design patterns as: Registry, Observer, Factory, ActiveRecord ,... and MVC a set of other design patterns and folder ...
0
votes
1answer
70 views

How to use Try/catch and database transaction in PHP and laravel

I'm planing to use Try/Catch and Database Transaction in Laravel5 and my own PHP project to validate any errors occurs then rollback avoiding lost my transaction or information during user do their ...
-1
votes
1answer
24 views

RSS feed topic categorization

I'm trying to make my own news feed from CNN's RSS feed (among a dozen other news sources). However, I've come across a problem that is actually quite complex, at least that's what I think. One of ...
82
votes
7answers
74k views

Is it bad practice to use <?= tag in PHP

I've come across this PHP tag <?= ?> recently and I am reluctant to use it, but it itches so hard that I wanted to have your take on it. I know it is bad practice to use short tags <? ?> ...
0
votes
1answer
51 views

React.js + Flux, immediate response during history back/forward

In Instagram (web), when you click back/forward arrows - I've noticed that the content isn't loaded from the server and it immediately show up. After reading the docs on react.js + flux, I had this ...
0
votes
0answers
68 views
+50

gearman or semaphore with symfony2

I want some way to store the user clicks on deals, categories and advertisements on symfony2 store. My situation: Basically, I am planning to use either messaging system using semaphore or integrate ...
-1
votes
0answers
34 views

Best way to maintain multiple projects based on a single Core?

In our company we have a SaaS Core. This Core contains functionality that is used among all projects we are currently building. These projects are based on PHP. We have 3 separate projects that are ...
2
votes
2answers
242 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 ...
1
vote
2answers
155 views

What is the best approach for 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 ...
1
vote
1answer
73 views

Fundamental difference between a static class and namespaced functions

I have been using "static" classes as a method to group functions with relating purposes under a common name that provides readability and maintainability to the code at the cost of performance and ...
0
votes
1answer
106 views

Question(s) about PHP PDO connections

Let's say I have a Db class [ db.php ] : <?php class Db { // class properties private $db_driver = ''; // dsn credentials private $db_dhost = ''; private ...
-2
votes
0answers
82 views

What's kind of real-time system are of high demand in software market? [closed]

Recently I'm doing some research on real-time web applications using PHP and javascript. Real-time chat and notification apps are commonly found. I would like to know what are the other real-time app ...
-1
votes
1answer
40 views

Keep php curl alive for subsequent new requests

I am trying to scrape a site using php curl. Initially captcha has to be provided along with username and password for authentication. After logging in, to view one of the page link again new captcha ...
0
votes
2answers
63 views

Is an approach to store classes that belong to a single feature in a single folder, superior to classifying them in several “community” folders?

in my project I am finding that I mix and match the following two patterns, when it comes to organizing classes in folders/namespaces: Modularized MVC Blocks ...
1
vote
1answer
105 views

How to compute Pricing of Product & Options based on User Option Selection and Pricing per Option

I am building a service for pricing options of a product and for pricing the product itself when product has various options. Example User selects some X options out of Y options available, where X ...
-3
votes
0answers
80 views

Password strength feedback

I'm creating a password checker. The user is entering the password in the check.php form and then the password is saved using another php add.php To validate the different policies, like character ...
0
votes
1answer
3k 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 ...
4
votes
3answers
1k views

How to deploy a single website to multiple physical servers?

Edit: I asked this question 3 or 4 years ago when I was new to web-development, the question looks a bit stupid to me today. I wanted to create a server setup of my own without relying on other ...
-1
votes
0answers
71 views

How to limit php condition so that program only run for a particular time?

I have to limit php wordpress plugin so that It only run for a particular time. Like I am making a website on which I have to make that amount of money paid by customer will be equal to number of ...
2
votes
1answer
170 views

Explain ServiceLocator pattern of ZF2

I am looking at this example: http://framework.zend.com/manual/current/en/user-guide/database-and-models.html Relevant excerpt from above: class AlbumController { public function ...
2
votes
1answer
18 views

Per-Module Unit Testing in ZF2

This question is about handling namespaces and unit testing in ZF2. Let's say I have a module called Application. I have constructed composer.json to be like so "autoload":{ "psr-4": { ...
0
votes
1answer
389 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 ...
3
votes
1answer
140 views

Dependency Injection & In-class Instantiation | Practical Limitations

Dependency Inversion is Good Inversion of dependency is good, it: Simplifies unit-testing Reduces coupling, allowing software components to be used interchangeably Keeps instantiation logic for a ...
0
votes
2answers
55 views

Should object enforce validation rules on read as well as write?

I have a class that enforces database-friendly formatting for some of its properties in the __construct() method. This guarantees that if a new object is created and saved, it will be saved ...
0
votes
3answers
540 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 ...
0
votes
1answer
537 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
1answer
41 views

Performance of changing img src via jQuery or adding as a class

Background I've been doing a bit of image manipulation recently in PHP/JS. The basic functionality is such: Web page loads, an <img> tag points to a PHP script which generates an image "on the ...
1
vote
2answers
290 views

Multiple instance of the same class?

I have a class named "Category" to handle all the operations and data about my categories. Now, my class is created however I need to find a way to build an object for each of the categories in my ...
5
votes
1answer
254 views

Evaluating data set with a string formula in php

I was tasked to update some conditions in an application. I have a data set to be evaluated, and it has been hard-coded in the application following way: $arr = array( 'a' => 'apple', 'b' => ...
-1
votes
1answer
105 views

Different instances on deserialization of php objects?

Suppose I have a class called MyClass, with a member variable 'var'. And the following scenario: echo '<pre>'; $x=new MyClass; $y=new MyClass; $x->var=$y; echo 'Checking for ...
7
votes
2answers
152 views

Am I using Zend Form library correctly? (I am effectively duplicating work in Controller and in View)

Brief Summary This question is asking for guidance on how to deal with Zend Form library that allows me to specify how to construct each form element (Controller side) and how to render each element ...
2
votes
1answer
156 views

Child class accessing its parent's method from Ancestor method

I find myself right now banging my head with the following issue (in PHP): I have an abstract base class, which has a non-abstract method, inherited and unchanged all over the inheritance chain ...
6
votes
1answer
443 views

How to make clear that a method can be overridden?

I have a library that I use in several applications. It has a method that returns a URL: class UrlBuilder { public function url($config) { $config = do_some_checks($config); return ...