Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.
0
votes
1answer
21 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
41 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
59 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
18 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
67 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. ...
-3
votes
2answers
68 views
Need advice regarding PHP frameworks for web application
I'm planning to have a portal developed that will be used for communication between the school and the parents. The site would need to have secure login authentication as the parents will need to log ...
-1
votes
1answer
75 views
PHP-Script to find the next free filename
I've got a PHP Script that creates a txt file using a form and
saves it under the filename "businesscard-1.txt". If i gonna run the
Script again it overrides the "businesscard-1.txt" with the new ...
4
votes
2answers
73 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 ...
-1
votes
0answers
36 views
Building an SSO server with OAuth2 [closed]
We have an authentication application that we use to sign in to all of our applications. We achieve somewhat single sign on by simply sharing the PHP session as all applications are on the same domain ...
3
votes
3answers
80 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
149 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
161 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
1answer
76 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
0answers
68 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
174 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
39 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 ...
-2
votes
0answers
30 views
The @copyright tag and years in PHPDoc [duplicate]
I currently use the standard PHP PEAR for my project, which asks me to include the tag "@copyright" in all my PHP files.
I'm looking at the documentation PHPDoc: ...
-1
votes
2answers
121 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
1answer
104 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
78 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
115 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 .=.
1
vote
3answers
167 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
189 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
197 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
125 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
81 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
0answers
35 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 ...
1
vote
1answer
91 views
How far do I separate Model code from Controller code when writing MVC?
I have some code where Controller depends on the Model, and in my case Model acts like a Database Access Object.
use FQDN\Model;
class Controller
{
/** @var FQDN\Model */
private $model;
...
2
votes
0answers
39 views
How to architect rule matching with multiple conditionals and outcomes
I'm working on allowing my users to create their own ruleset for data that's coming in. All of the data below is sample mock data and not in relation to our product. Example of a rule (there can be ...
5
votes
1answer
87 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 ...
-3
votes
0answers
43 views
View being rendered twice [migrated]
I'm making a small mvc based website and ive run into a small issue.
I have a form that as a dropdown which should be populated with values from the database.
My model code is:
<?php
...
2
votes
0answers
53 views
Fine-grained data level permissions on a laravel RESTful API
The problem:
We want to restrict access to properties returned from our services.
Details:
We have route level permissions working with no issue.
For a user that can view /product/{id} for ...
1
vote
0answers
45 views
How to persist a session cookie in a PSR7 request/response middleware?
I am building a package that implements native-like sessions in a PSR7 middleware architecture.
I created a middleware which is responsible to create and persist a session cookie. The session is also ...
1
vote
2answers
86 views
How to sync the data from the same user across multiple devices
I'm working on a small fitness app in which the user (whom is authenticated with the a server) could create their own workout plan which will be synced with a server.
The problem with this is that ...
3
votes
3answers
242 views
Modern recommendations for password recovery
I'm going to implements password recovery in my authentication. I haven't put this together in a while and wondering if there is anything I ought to be aware of.
My idea at the moment is:
User ...
0
votes
0answers
53 views
Data Mapper pattern vs. model encapsulation
I am currently developing my first custom data mapper layer but have run into a conceptual problem that seems to be glossed over all books and guides I have read.
My problem is as follows. My data ...
0
votes
1answer
118 views
Is there ever a reason to use variable variables in PHP rather than an array? [closed]
Is there any situation where an array is not suitable but a variable variable is? I cannot think of one or find one on any Stack Programmer Q&A.
<?php
$foo = array();
for($i = 0;$i < 3; ...
1
vote
1answer
80 views
Make PHP sessions truly last until the browser closes, and regenerating session on page requests
We have an issue where sessions are ending after a short time, 1440 seconds according to gc_maxlifetime settings which seems consistent with the issue. The PHPSESSID says it will expire when the ...
1
vote
0answers
44 views
How to handle optional dependencies in php?
At my Job I'm currently on refactoring a very old php CMS. By now, "code handling" was done by simply copying the whole thing and modify it to fit whatever was needed for this job to be done (actually ...
0
votes
0answers
63 views
Proper way/place to apply decorator pattern for view layer in mvc
I have an array of model objects containing data some of which is states represented by integers. In the view these states are shown as icons and tooltips. The tooltip is needed only in the view and ...
0
votes
0answers
30 views
“remember me” functionality but user database on another app on another sub-domain
I'm considering how to add remember me functionality to our app. However we have our app, and a separate app that handles authentication on another sub-domain. When authenticating from one of our ...
2
votes
1answer
61 views
Set authenticated users session cookie's to long term, but others to short term?
We want to extend the session duration for our users. I guess it doesn't matter for users who are not authenticated. We can create a PHPSESSID cookie for them and if it expires when they close their ...
0
votes
1answer
108 views
Is it worth it to follow code conventions of Netbeans? [closed]
I am always not able to follow Netbeans default coding conventions like the following
Function should be N lines only
Method Length is N Lines (M allowed)
Warning: Do not Access Superglobal ...
0
votes
1answer
84 views
Saving an image in MYSQL vs saving to a folder [duplicate]
Is there an advantage to either method and/or a risk to either? Looking to upload JPG or PNG files only with a size limit of ~3mb with reduction done before insertion.
0
votes
0answers
29 views
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
vote
1answer
68 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 ...
0
votes
0answers
36 views
Change API response with minimum code changes
My Application is built on Laravel and currently has the following components :
Models
Dictionary
Word
Controllers
DictionaryController
WordController
It's a JSON API, so views are nothing ...
2
votes
0answers
89 views
How should I store usernames and passwords for user login using php/cassandra?
I am new to NOSQL and Cassandra. I am not sure if I should store usernames and password in Cassandra. If I should, what is the best way to do that? I am getting lots of conflicting ideas from ...
2
votes
1answer
98 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 ...
3
votes
3answers
182 views
Unit Testing and 3rd party packages. Do I mock or not?
I'm just getting used to unit testing and on my new project I decided to adopt a TDD approach.
My code below is to test the UserServices class which is responsible for creating a user, deleting a ...