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

learn more… | top users | synonyms

-2
votes
0answers
20 views

Why is error suppression ALWAYS a bad thing? [duplicate]

It seems to be the general consensus that there are absolutely no scenarios in which an error should simply be suppressed, e.g. using the @ operator in PHP. But if, as an example, I want to do ...
1
vote
2answers
56 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 ...
-4
votes
2answers
62 views

How to insert large text into a DB with PHP?

I have a function that generates a random text with about 8,000 characters. This text is generated at the time of first access the page, based on some parameters. I would like this text to be ...
-2
votes
0answers
38 views

Database structure for an Android chat application

I have a structuring or rather designing problem. I am developing an Android chat application and I need to know if anyone has an idea on how the database should be structured to allow group and ...
1
vote
1answer
43 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, ...
-4
votes
0answers
50 views

Computer monitor App [on hold]

Background: I' m a beginner progammer who needs guidance in building an app for linux, (Ubuntu to be more specific). I want to develop an app that does the following things: when the laptop starts ...
-3
votes
1answer
55 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 ...
0
votes
1answer
95 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 } } ...
1
vote
1answer
86 views
+50

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 ...
0
votes
0answers
14 views

PHP array implementation what hashtable's 'bool persistent' does stand for? [migrated]

I read So let’s just say that persistent specifies that the hash table can live between multiple requests. In Nikic's blog about PHP array implementation There is no further information in ...
-1
votes
2answers
136 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
17 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
18 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
2answers
46 views

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

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
0answers
16 views

Form Filter and Calculator for Tabular Data [closed]

I am looking to create a new website but I am lost as to how best to go about things and where to start. I am wanting to create a website to store all data in a tabular form just like a spreadsheet. ...
2
votes
3answers
111 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
98 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
vote
1answer
58 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 ...
-5
votes
0answers
41 views

Avoid line breaks in a div [migrated]

How can I avoid line breaks in a div when I use a php funcion. My code is HTML is <div class="toolbar"> <div style="float:left; "> Profile <?php ...
1
vote
2answers
143 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
0answers
42 views

API Wrappers: Should I return Objects or arrays? Or maybe there is no difference?

I have some 3rd party API that I'm building a wrapper around it. The API is "...a RESTful web API, to which you POST data to, the API response is an XML or JSON output." I wonder, should I return ...
-2
votes
1answer
57 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
50 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
70 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
22 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
71 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. ...
-1
votes
1answer
87 views

PHP-Script to find the next free filename [closed]

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 ...
5
votes
2answers
102 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
81 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
151 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
162 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
92 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
94 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
178 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
41 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
126 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
184 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
79 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
117 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
168 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
192 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
198 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
88 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
37 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
93 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
41 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
101 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
0answers
57 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
52 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 ...