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
23 views

Is pchart 2.0 free? [on hold]

I am develloping a website of horse racing pronostics and I just wondering if pchart can possibly be free for my case... Basically, I will offer to my customers to pay for getting my pronostics. ...
-5
votes
0answers
49 views

Send scheduled emails with conditions [on hold]

I have to edit a Laravel project and add a function to send scheduled emails with certain conditions. Basically the project is about a ticketing system with which some companies have to interact. An ...
-2
votes
0answers
81 views

Run code once at deployment and never again. Possible? [on hold]

For any web applications, there are 2 stages, 1st, before request processing; 2nd, starting to process the request and further. And there are plenty of cool frameworks out there, viz. laravel, CI etc. ...
1
vote
0answers
31 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 ...
-1
votes
1answer
43 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
423 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 ...
-3
votes
0answers
52 views

PHP display image on same page from DB with jQuery Ajax or iFrame? [closed]

I have used separate solve.php because headers should be set before any echo statements. Requirement: To view image on the same page when click view. What I did: I coded already jQuery ajax method ...
-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
213 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
51 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
82 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
73 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
162 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
96 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
0answers
22 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 ...
2
votes
3answers
126 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
0answers
91 views

How to insert large text into a DB with PHP? [migrated]

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
82 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 ...
2
votes
1answer
52 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
73 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
101 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
203 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 ...
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
156 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
19 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
32 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
59 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
96 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
156 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
56 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
76 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
25 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
121 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. ...
5
votes
2answers
147 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
86 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
157 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
167 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
142 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
101 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
182 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
77 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
132 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
261 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
123 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
169 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
195 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 ...