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

learn more… | top users | synonyms

-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 ...
1
vote
1answer
19 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 ...
0
votes
0answers
36 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. ...
-4
votes
0answers
55 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 ...
-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
43 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
-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 ...
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 ...
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 ...
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). ...
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 ...
-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 ...
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 ...
-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 ...
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 ...
-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
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
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 ...
-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 ...
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 ...
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
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
0answers
37 views

Where does export file code belong in an MVC implementation that is designed mainly for HTML

I have an MVC website set up with a base view (Layout.php) containing HTML header and footer code. Other views (such as CarView.php) will extend this class. One of the methods in this class is ...
-2
votes
1answer
53 views

php base64_encode simplified answer

What are practical uses of base64_encode and base64_decode? At what particular situations are they used? For example, in terms of security? What is the usage of using this function when sending an ...
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 ...
-1
votes
0answers
9 views

Lets develop a session timeout! [migrated]

Important definitions: session.gc_maxlifetime - (default 1440 seconds) defines how long an unused PHP session will be kept alive. For example: A user logs in, browses through your application ...
3
votes
1answer
231 views

Help in writing more generic code

I'm doing a php MVC project using code igniter. I have two models, a and b. Each class contains four functions (insert, delete, update and view) and their implementations are almost the same with ...
-1
votes
1answer
53 views

Any Non-Singleton PHP PDO Db Connection Examples? [closed]

Are there any good examples of non-Singleton PHP PDO Dbfactory or connection classes people can point me in the direction, or perhaps even briefly illustrate. I am interested in learning both support ...
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 ...
1
vote
3answers
79 views

Multiple items in a single column SQL

I'm creating a charter database structure. I'm trying to figure something out, I have read on here that databases should be normalized. Now, I'm a bit confused on this because I believe I have ...
1
vote
1answer
167 views

Should I have code that only exists for testing?

I have a service class which is responsible for instantiating repositories and using them. It makes an external Http request which ideally I would like to mock for testing. However, I am not quite ...
1
vote
0answers
107 views

Making code more “modular”

As an semi-experienced procedural PHP developer, my OOP still needs a lot of work. I am still working through SOLID principles and other theories and guidelines of OOP, and am stuck with something ...
2
votes
3answers
129 views

Is there any low level way to get shifted or unshifted bits which results from bitwise operations?

I was playing with bitwise operations and a question about counting true bits of any positive integer value, so I solved the problem with bit shifting, so I just thought if there would be some way to ...
2
votes
1answer
55 views

PHP Where do routes end and queries begin

I have a PHP app and 90% of the code is about managing multiple MySQL tables. But there are other systems like a User system and an Admin system, etc. All PHP requests are processed in one App file, ...
-3
votes
1answer
79 views

Is it possible for $this to return a __construct?

I am currently working on my PHP skills and at the moment I'm working with classes. What I want to do is to create a class for which I can echo the object. I have the following example: class ...
1
vote
1answer
102 views

Should “magic” getter functions be used for dynamically calculated values or just existing properties?

For example, if I had a Customer class and wanted to get all orders by them. Would it be better to do: class Customer{ public function getOrders(){ return results from db query } } ...
2
votes
2answers
209 views

The best way of handing a form post as an API type of submission

I have recently been tasked with a project to create an API that handles a form post using PHP. I have never done something like this before and this will be handling payments so I would like to do ...
-1
votes
2answers
160 views

Open source project - framework or core PHP?

I am working in some open source project in PHP. My question is, should I make it using some kind of framework, say Laravel, or in plain PHP, in a hope for a large no of programmers using it? Btw, ...
0
votes
0answers
20 views

Routing with a crowded bootstrap

I'm developing a Hack application with a front controller. I've opted out of using a framework, and though my router is pretty naive, it's done its job. The highest-level components are in the global ...
0
votes
0answers
36 views

Clearing Laravel cache on REST web service and front-end

Our REST web service and front-end are both on the Laravel Framework. The REST service and the front-end share a memcached server. The endpoint response and the data received on the front-end are ...
-3
votes
2answers
60 views

How to allow Object creation of a class on only particular classes in PHP? [closed]

In PHP, let there be four classes A, B, C, and D. None of them inherits the other. They are all independent classes. Now, I want only B and C to be able to create Objects of the class A. D Should not ...
2
votes
3answers
116 views

Should all PHP requests be centralized?

In a multipurpose website (user system, lots of database operations on different tables, schedule creators, …) should all PHP request be centralized to one app? For example, my current set up is like ...
5
votes
1answer
104 views

What is the impact of re-defining a dynamic type variable (such as in PHP)?

PHP variables are dynamic in type so I can do: $x = 'hello world!'; $x = strlen($x); Sometimes this is trivial and I could save many lines of code, but it reduces clarity. I'm using a text ...
-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 ...
1
vote
2answers
162 views

Where is password hashing/salt logic applied?

I went through a PHP/JS tutorial on user registration with secure hashing (no salt though) using sha. What I didn't understand is why the hash was generated on the client. Also, I don't understand the ...
-2
votes
1answer
58 views

Multiple arguments for last parameter

I have function that has three parameters, called key, value and attribute. Parameter attribute may be empty or have within two arguments. Code of function below is shortened (deprived of arguments ...
0
votes
1answer
63 views

Should Laravel's App::make() be considered a dependency?

I think the question in general is best summed up as, should Laravel's App::make() be considered a dependency? On the one hand it can instantiate any number of different implementations, so maybe it ...