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

learn more… | top users | synonyms

-4
votes
0answers
39 views

How to fix text down much rows [on hold]

hi i'm building a forum system. and if try to send a post with down rows it sees like == hello, my name is stav == and want it sees == hello, my name is stav preg: $subject = stripslashes($...
0
votes
1answer
44 views

Use redundant data in database design when have multiple relation

In my web application users can submit their advertises and buy package for advertise (packages are used for priority of showing advertises) Database schema is like this: **Package: id, title, ...
1
vote
0answers
46 views

What would you call this design pattern? MVC or PAC

I have been reading and researching about MVC, HMVC, MVP, MVVM and PAC design patterns when I came accross this article by larry garfield > MVC vs. PAC My Implementation: Think of a modular app ...
-2
votes
0answers
22 views

Emitting events from PHP [on hold]

I have a website with that many Offices are connected using Browser as Client. Now I am looking for some kind of idea that if we receive a news for specific office, can we send a message to Client as ...
0
votes
0answers
27 views

Design from API documentation to code

I have a full API documentation made of uris, request and response bodies ready to use. Uris are all externals, and I have to first visit an entry point that'll give me a token, and then use that ...
1
vote
1answer
94 views

Functional Programming in PHP

Modern PHP is mostly written Object Oriented. Other than the fact that there is inertia towards the Object Oriented in the PHP community, is there anything about the language itself that would make it ...
-2
votes
0answers
39 views

Private chat window in PHP chat [on hold]

I am currently building a chat as a personal project, and I have no idea how to solve this problem. I need the possibility to make a privat chat window, for private chats between users. However, ...
2
votes
0answers
24 views

App opening standard browser instead of active browser

Say you have a smartphone with two browsers, DefaultBrowser and OtherBrowser. You visit the webshop by opening Otherbrowser, and proceed through the cart steps At the end, you go from OtherBrowser ...
3
votes
3answers
325 views

Is it good practice to use a single database connection?

The PHP codebase I'm working on has an utility class that returns a database connection. The implementation looks like this: class Database { private static $conn; private static $init = false; ...
1
vote
1answer
136 views

Can I add to a built-in function?

I want be to be able to re-write the code of an existing PHP function in an abstract manner. Here is an example: scandir() scans a directory for files and folders, and returns the relative paths '.' ...
1
vote
0answers
45 views

Dynamic Printing Options

I believe this is the correct community to post this question in, if not please point me to the correct one. Overview: Current web app gives users the ability to print labels from specific printers. ...
1
vote
3answers
74 views

Return values for a delete function in php

I am writing a wrapper function for database calls, and I am confused about the best way to handle the error cases. The function has only one argument, the id of the object to be deleted. I've ...
-1
votes
0answers
29 views

Shuffling of MCQ's in my examination portal [on hold]

the screen shots attached are structure of database of my exam portal, one picture represents the question bank and second represents the test details.Test ID is acting as a primary and foreign key. ...
-1
votes
0answers
30 views

Principles for secure user login/authentication [closed]

Backstory: In my from-scratch PHP/MySQL web development projects, I often start (and end) working on a secure user authentication. I'm self-taught and never certain that my site is adequately ...
0
votes
1answer
58 views

Manipulating DOM via script or rebuild website - which is better?

Let's assume you want to change what user sees on the website. There are two ways to do that: a) manipulate the DOM via JavaScript, but user has to download whole script, with possibility he may not ...
0
votes
0answers
54 views

How to search through an array of objects?

I am using an array of objects to store data to render a page. A few examples of data an object can contain: PHP filepath for an include CSS filepath for CSS files Meta data of the page Element ...
-2
votes
0answers
56 views

How does one create a PHP page router controller? [on hold]

I am making a PHP controller that should route pages on my website. It is my first attempt. Can someone revise this code and tell me if this makes sense or not. (never mind the logs array, I use it as ...
2
votes
1answer
42 views

Where should view-specific data/logic be defined in a PHP MVC application?

After many hours of research and thinking I have found an understanding, then coming to question it again, I am struggling to find something concrete which I can grasp and apply to my code in a ...
1
vote
2answers
170 views

where to put which code in MVC model

I recently picked up learning PHP and MySQL and I am trying to build a small usersystem as a coding exercise. While learning to use classes and functions, I also stumbled upon the MVC model and would ...
2
votes
2answers
97 views

Can a single Factory be used to create similar in purpose, but different in focus objects?

I am concerned about whether or not I am using FactoryMethod correctly. Background: I am refactoring legacy code and I have identified a pattern: there is a God Object that is created in memory,...
-1
votes
0answers
51 views

How to send an email attachment from form using codeigniter [on hold]

Can anyone help me about how to send an external file attachment directly from form type="file" through the mail using PHP Codeigniter.
0
votes
0answers
104 views

how to create triadic relations in laravel framework

I need to create triadic relation in laravel framework. Consider three models: Card, Notes, User. Card is related to notes and user, while they are related to each other. Now in models, when the ...
0
votes
4answers
485 views

Do i have to make all my website PHP with embedded HTML to make a good secure website?

I see all websites (THE big ones) make both PHP and HTML in same page .. Do I need to make all my website pages as PHP and embedded HTML inside it ? Can't I make the website all as HTML Pages and PHP ...
-1
votes
0answers
63 views

Is it better still use Java\Spring MVC or a lighter technology as PHP\Laravel for a new project?

I am a Java EE developer that obtained the Spring Core certification (related to Spring Framework). In the last year I have gained experience with this framework. I am also pretty confident in the ...
1
vote
1answer
111 views

Php-mysql injection

<?php error_reporting(E_ALL); //ini_set('display_errors', 1); $db_server = "localhost"; $db_name = "2"; $db_user = "root"; $db_passwd = ""; $connection = mysql_connect($db_server,$db_user,$...
0
votes
0answers
33 views

Strategies to manage approvals of orders together with a log

Backgound I need to develop a system that handles orders that needs to be approved by supervisors (or users with more privileges). A log have to be implemented to show who created the order and when, ...
0
votes
2answers
63 views

Reading the result of your command with the Command Pattern

I am currently looking into developing a new system utilizing hexagonal architecture and the commandpattern facilitated by a commandbus like tactician (it's a PHP system). Now I really like the idea ...
2
votes
0answers
77 views

Are there downsides to writing PDO/mysqli statements into my code directly vs using my own redirect wrapper methods?

TL;DR: To access DB functionality in my codebase I currently use a custom layer throughout the code. The layer needs an upgrade in order to begin accepting prepared statements, which it currently ...
1
vote
1answer
75 views

How to display recent post on website and make own search engine ? With PHP

On OLX like Website , Anytime a user posts a new ad. It comes in top of the page. No search is involved in it. Which technology we can use to make such functions. Suppose X is visiting my website ...
1
vote
1answer
51 views

Accessing i18n objects from different scopes

I have been building a personal framework of mine which started off as a way to learn the MVC pattern and has progressed now into something that I like more than most frameworks out there (which is ...
0
votes
0answers
50 views

How should i handle deeply nested data with codeigniter/mvc?

I want to build a website with categories, pages, sections and slides. Hierarchically it should look something like this: [category 1] [page 1] [section 1] [slide 1] ...
0
votes
2answers
215 views

A few questions about model objects in a MVC

I have a few questions about how to implement models and what the results are of those implementations: When I only need a few variables set, isn't it memory consuming to create an entire object? E....
0
votes
1answer
46 views

Laravel Eloquent - Filtering results and eager loaded results

So here is the use case: You have users and they have many addresses. Say you want to filter and eager load on addresses (say...only US addresses). In order to do so you have to filter the eager load ...
2
votes
3answers
168 views

How to gently steer a giant PHP app toward better practices? [duplicate]

So I'm responsible for maintaining and enhancing a PHP codebase that runs to around 1,100 files and 120,000 lines of code. In general, it's not terrible, although since it was written over some 10+ ...
-1
votes
2answers
133 views

The best way to create a PHP chat system

I'm into creating a php based web chatting system. About 1000 concurrent users across the world will be using it, so what would be the best tech to deploy? As I did some research online, mainly I ...
0
votes
1answer
36 views

Creating a facet filtering using Elasticsearch

I have been asked to create a filtering functionality for e-commerce application written in PHP. Since the app is using MySQL database, I made the decision to use Elasticsearch with Logstash and ...
1
vote
1answer
40 views

PHP primitive types: are objects primitive types?

I am reading through PHP Objects, Patterns and Practice 4th Ed and on page 41, Constant Properties chapter says: Constant properties can contain only primitive values. You cannot assign an object ...
-4
votes
1answer
51 views

PHP access external website like human access

I would like to code and API, the API would access an external webpage like human, the external site needs user, pass and verification code/capcha. PHP application will access that page by providing ...
2
votes
0answers
170 views

Symfony2 - Best aproach for a plugin system

Symfony2 is handling all its things in bundles in /app or in /vendor. This is fine, if you are handling and managing all by yourself or Ops that handle all needed things. But I haven't found a good ...
0
votes
1answer
59 views

Conditional factory

I need to perform a payment and I have two payment methods: FirstPayment and TokenPayment, which both implement PaymentInterface interface PaymentInterface { public function pay(PaymentRequest $...
1
vote
2answers
100 views

Planning to convert PDF to JPG, Annotate the image, Reconvert to PDF

I have a feature where scanned exam answer books need to be digitally annotated and marked. The scanning portion of the work is with another vendor who refuses to scan in any format other than PDF as ...
1
vote
1answer
60 views

Why does ORM persist() functionality use references to populate insert_id and not return?

My understanding of how ORM persist works: //ORM "persist" oversimplification function persist(&$entity) { ... $insertId = api_actual_db_insert(...); $entity->setId($insertId); } /...
1
vote
1answer
116 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
1answer
113 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. ...
0
votes
0answers
30 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 ...
13
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 testable?...
3
votes
1answer
106 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). ...
-1
votes
1answer
204 views

How to use Try/catch and database transaction in PHP and laravel [closed]

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
vote
1answer
76 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 ...
-1
votes
2answers
99 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 ...