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

learn more… | top users | synonyms

-1
votes
2answers
103 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
2answers
64 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 module/Album/Feature/Controller/...
-1
votes
1answer
86 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
56 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 correctly....
2
votes
1answer
35 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
57 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 CarView-...
-2
votes
1answer
60 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 ...
7
votes
1answer
446 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 make_url(...
4
votes
1answer
249 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
66 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
149 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
89 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
172 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
114 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
137 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
59 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
100 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
105 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
215 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
187 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
22 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
65 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 ...
2
votes
3answers
119 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
105 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
109 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 $x->var===...
1
vote
2answers
171 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
60 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
96 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 ...
1
vote
3answers
82 views

Should I keep “redirect only” methods in my Controller?

Controller: function indexAction() { if ($condition) $this->renumPosition($id); //LINE #1 } //Redirect only - function's sole purpose is to call another function function ...
-1
votes
1answer
28 views

Class that prepares strings from HTTP requests at PHP controller level

I have a library /Web/ such as follows /Web/ Builder/ Builder.php Exceptions/ ExceptionHandler.php JSONSerializer/ CategoryJSONSerializer.php ...
0
votes
1answer
264 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. ...
6
votes
2answers
306 views

DDD: Creating reusable modules and service type distinctions (Domain, Infrastructure, Application)

So after reading "Implementing Domain-Driven Design by Vaughn Vernon" I've decided to refactor my code for better re usability by isolating what I believe to be core domain concepts into separate ...
3
votes
3answers
95 views

Why do we separate Data Retrieval from View?

I am seeking a good argument for: Why is it NOT a good idea to embed data retrieval code in my view? Example <tr> <td>Product</td> <td><select name="product"> ...
1
vote
1answer
173 views

Which is better to call: API or Database?

I'm building a web app that hits up some APIs to get JSON dumps of data. I'm running across a problem. I can either grab all the data, dump it into a DB, then pull it from the DB as needed. OR I can ...
3
votes
1answer
183 views

Why are SameAsClassName() constructors deprecated in PHP7?

According to the PHP5 manual, __construct() was introduced in PHP5 as a replacement for SameAsClassName() constructors, and from PHP7, the old style is marked as deprecated, so in future versions, ...
-1
votes
2answers
281 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 ...
3
votes
1answer
173 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 ...
1
vote
2answers
186 views

Software Design, a fitting Design Pattern?

Currently we need to interface with a REST API. The only problem we have implementing this is choosing the right approach. We’ve done this by using Resources – for example a Photo Resource that has ...
1
vote
0answers
82 views

Sending large amount of messages async

The scenario is this: I have web based service that does regular request processing and it's doing persistence into db etc.. Fast response to the client is crucial. So now the average request is about ...
-1
votes
2answers
166 views

What kind of license to put a private project?

The project in which work is private for commercial purposes and not its source code is distributed to anyone. Only the functional application shown consumers through a website. It has the following ...
1
vote
2answers
309 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 ...
2
votes
2answers
81 views

How do I decide whether to make an Input/Output data type an array or a class?

I have some input that I send to a computational library, which processes the input and produces some output. Question: What considerations do I take into account to help me decide whether the ...
-2
votes
1answer
133 views

What is the difference between these two php operators? [closed]

What is the difference between these 2 PHP operators ? The first one is = and the second one is .=.
2
votes
3answers
179 views

Using multiple languages

I currently have a website running PHP laravel. We came to a point where we want to add a user-backend -- where users sign-up and can access functions when logging in. My question is; Is it possible ...
3
votes
2answers
198 views

Extending the flyweight pattern: an oxymoron?

I'm developing a BNF parser in PHP, for my own flavor of BNF. To keep the resulting parse tree, consisting of objects, as lightweight as possible, I decided to use the flyweight pattern for literals (...
4
votes
1answer
212 views

Do I have to stop using Dependency Injection to keep object debug printouts small?

Say I have a large object - think EntityManager of an ORM such as Doctrine, or a custom DAO object, or what have you. Object, output of which is required to be used inside a class, but the object ...
1
vote
2answers
137 views

Safety of magic setters in PHP

I don't know how in else languages, but in PHP seems to me that they are very unsafe way how to set value of any member variable - because one setter cannot easily validate input for many variables (...
3
votes
1answer
99 views

PHP OOP, structuring my objects properly

I have an architecture similar to this: User (Name, Email, ID...) ---- Studios (Name, Location, Description...) ---------- Videos (Title, Description, URL, Length, Views...) Simply put, a user can ...
1
vote
1answer
88 views

auto generated web CMS for pre-existing SQL db?

What I'm looking for is a way to auto-generate a simple web-based CMS for a simple pre-existing SQL database. To be used by 'app administrators', not the general public. Something that: allows ...