Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [php]

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

6
votes
0answers
132 views

Object-oriented WordPress plugin

Note: This plugin is / was never intended to be submitted to repo just for personal use but the questions still apply to general Plugin Development. This plugin listens for ...
5
votes
0answers
133 views

Checking game objects versus each other to determine targets, comparing arrays

I have a flight class that looks like this: ...
5
votes
0answers
9k views

Simple Router class

I made a simple routing class that I like to get reviews for, mostly because I do not know how to make it SOLID, since I even made this class separate from the HTTP response/request for the sake of ...
5
votes
0answers
2k views

php swiftmailer two message instances with one mailer instance?

I created a simple function for swiftmailer to send two different messages for support and client. Not sure i did it the rigth way as I am using two different instances for message and one mailer ...
4
votes
0answers
54 views

Naive php web hook endpoint for use in a production environment

Below is the WebHook endpoint in its entirety. I have five seconds to acknowledge if the payload is correctly formed. After that, the payload is inserted into a queue for processing. Importantly, ...
4
votes
0answers
61 views

WordPress contact form plugin PHP and WP_REST improvements

TL;DR This month I wanted to improve my WordPress knowledge and create a simple form that wasn't bloated with features but was secure. I wanted to make sure this plugin improved my knowledge of: ...
4
votes
0answers
177 views

Crawling thesaurus for a synonym

I have just finished core functionality for Tehsaurux. It crawls three thesauruses and will find a random synonym for you. It works with PHP agnostic and Scrapy for Python. I think the two main ...
4
votes
0answers
106 views

Curl-based REST Client Library (round 3)

This code review request relates to this code review which covers the basic single REST call use case in this this REST client library. This code review covers the classes and unit tests for the ...
4
votes
0answers
185 views

Let users create custom blade templates

Problem: I need to let my web-app users create their own blade layouts. The content shall change based on what is in the database, hence their layouts should become dynamic in nature. With only the ...
4
votes
0answers
180 views

In-memory file system context for the behat PHP BDD testing framework

I wanted to come up with a 'utility' context to enable testing of the file system with behat. Specifically this is aimed at helping with the behavioral testing of php command line applications that ...
3
votes
0answers
19 views

Wrapper for Google_Service_Calendar as a Symfony service

My app interacts with Google Calendar. This Service wraps Google_Service_Calendar: ...
3
votes
0answers
26 views

Use a pattern for fields validation

I need to validate the fields of user sent by an API. All works fine but the only one problem is that I don't like the solution is not an OOP solution. In the controller I call the service created by ...
3
votes
0answers
106 views

Symfony: Encrypt ID's on postLoad event

I am building an application that is becoming some kind of social media platform. I need to work a lot with the entities ID's in the HTML and Javascript for the purpose of AJAX calls. However, for ...
3
votes
0answers
802 views

Full text search for multiple words using Laravel and MySQL

I'm using Laravel 5.6 and MySQL. I need to search multiple columns for a single word or multiple words (e.g., "camhandle", "cam handle"). The way I was originally doing it was just using ...
3
votes
0answers
1k views
3
votes
0answers
55 views

Drupal 8 Content Import via CSV Implementation

I am implementing a way to import content into Drupal 8 via a CSV. This CSV contains various fields such as node ID, title, body, etc. It has been working great but I am very concerned about how long ...
3
votes
0answers
319 views

Laravel polymorphic usage

I am fairly new to Laravel and have implemented a many to many polymorphic relationship to a model where you have two tables that act as polymorphic references one is for content (text information ...
3
votes
0answers
49 views

Optimize travel sales person algorithm

I'm trying to find the way to optimize travel sales person algorithm? It's pretty simple but takes a lot of time to calculate best possible route. What do you think? ...
3
votes
0answers
307 views

Laravel Account models

This library is part of accounting system. Two major models are involved. For every transaction there is an entry in AccountTransaction model and corresponding 2 ...
3
votes
0answers
55 views

Class to build and execute dynamic SQL statements

I'm uncertain about proper OOP design since my teachers are explaining OOP very vaguely. Do I need to use the constructor and the getters and setters like this or am I better off removing the ...
3
votes
0answers
78 views

PHP Laravel function to search for ads in MySQL

I am new to the Laravel framework. I have recently written a function which gets called through a route. The function is created for two purposes: Get ads from a particular city based on provided ...
3
votes
0answers
321 views

PHPUnit testing my custom helper Facade classes in Laravel 5.5

I have been reading up on TDD and it's something I genuinely want to learn and be good at. This is something I haven't been doing as a developer and I thought it's about time I get into it. These are ...
3
votes
0answers
1k views

Simple OO MVC PHP framework

I've been working on a simple MVC PHP framework on and off for the last nearly 12 months, so I thought that I'd put it out there. The project began as a way to mentor and teach a junior (or a more ...
3
votes
0answers
45 views

Custom WordPress Menu

I have recently delved into the world of OOP programming with PHP. I wanted to add my own custom menu to the Wordpress Admin area, and came across a tutorial, which I have followed, and the code is ...
3
votes
0answers
67 views

Building a Survey Data Collection project in PHP

I'm building a survey data collection. Currently, I am done with building the prototype. It serves as wizard like control to navigate through various pages in a survey project. app/index.php ...
3
votes
0answers
38 views

Create archive webpage for newsletters based on nested array

I am creating a webpage for my newsletter archives. The archives are divided by year (currently there is only 1, but there could be many), then by topic, before listing each newsletter. There will ...
3
votes
0answers
80 views

Write to terminal and buffer

...
3
votes
0answers
58 views

Fantasy league tracker for Game of Thrones

So I've just started learning about MySQL and PHP to create a fantasy league tracker for Game of Thrones for my office. I got it to technically work fine, but I think it's way clunkier than it has to ...
3
votes
0answers
811 views

PHP routing system

I made a routing system for PHP inspired by Symfony's router composed of a few classes. First I am using Symfony's HTTP Foundations component. Then, I am emulating the classes in the routing ...
3
votes
0answers
69 views

Request handler based solely on reflections ver. 2

This question is connected to the previous one: Request handler based solely on reflections I have edited the code, taking tim's answer in regard, editing the Kernel class cohesion. ...
3
votes
0answers
69 views

Extension of PHP `round()` for PHP_ROUND_UP and PHP_ROUND_DOWN - follow-up

The original question can be found here. While looking at PHP.net this afternoon, I saw a comment in round() for two functions for rounding ...
3
votes
0answers
14k views

JWT - Simple API example

I have created this fake API just because I want to learn how to use JWT. It is a simple unsigned token exchange with two methods call: login and adminPassword. I've used https://github.com/lcobucci/...
3
votes
0answers
392 views

PHP MVC Service Layer Role

I wrote a series of questions in a previous post, and a user recommended that I separate the questions. I have made the switch from procedural programming to object-oriented programming. I have ...
3
votes
0answers
516 views

Processing database data into a multidimensional array

The purpose of this code is to get data from the database and output it into a multidimensional array in JSON for my web app. But my gut instinct is telling me this code is way too messy and just ...
3
votes
0answers
178 views

Building the HTML body view

I created a library class in CodeIgniter that handles building the HTML body view. This class builds the body, adds content and adds javascript element tags at the end. The body is built by using a ...
3
votes
0answers
754 views

Web service for Android clients to store images

I wrote this code for Android server interaction. The way I built the client was an onSharePreference of strings includes photo encoded to a base64 ...
3
votes
0answers
871 views

“Table Data Gateway” pattern

Using the table data gateway (TDG) pattern, I created a class QuestionGateway for retrieving, adding, updating, deleting, and sorting multiple-choice questions. <...
3
votes
0answers
819 views

Laravel Testing: Is this testing too much of the inner workings?

So I'm using laravel for a project and have a InvoiceRepository and a InvoiceRepositoryTest and I have written the test first ...
3
votes
0answers
104 views

Use of die() in flow control - proper and sensible?

Designed for OpenCart, vQmod places or replaces bits of code based on XML files. The following three versions of the code achieve the same goal, which is to ...
3
votes
0answers
4k views

Update database, refresh the page to show changes, show a success message

Follow up question for: Update database, reload page then show a success message I have a table of articles, in each row is a button to activate / deactivate the ...
3
votes
0answers
581 views

Building a console application using a DI service container

I am working on a project that will allow developers to create a console application using a dependency injection service container. Both the console and container are Symfony components with some ...
3
votes
0answers
647 views

Tiny MVC - Handling validation / sanitization in a model

I'm fairly new to MVC concepts and PHP input validation. I'm open to all input, but I'm largely wanting to know if the following: Follows the MVC pattern correctly - if not, how can I change it to ...
3
votes
0answers
2k views

Unit testing event triggering

I am writing a unit test for a Dispatcher that will route a HTTP request to a specific Controller and invoke a specific method on that Controller. It will also trigger various events at different ...
3
votes
0answers
215 views

Getting colors from an image PHP

I am working on a site that themes itself based on images / logos. I have built the class that gets the colors from an image, shown below. I am fairly new to OOP with PHP, and I'm looking for feedback ...
3
votes
0answers
641 views

CakePHP Best strategy for getting HABTM data in multiple ways within the same tool

School HABTM AthleticDirector I am building a tool for assigning athletic directors (ADs) to schools. The tool has a school menu/filter which, when selected, shows a list of ADs already assigned to ...
3
votes
0answers
128 views

Hooks class for basic plugin functionality

I've built a small hooks class for adding some capabilities of basic plug-in functionality. Is there room for improvement? I am just beginning to learn OOP. I ...
3
votes
0answers
100 views

Getting a list of manufacturers from a database

I'm new to Zend Framework. Can you help me optimize this function, which gets a list of Manufactures with some conditions from a database? ...
3
votes
0answers
100 views

Keeping track of voting

There is HTML that triggers the code below I want to disallow executing the script more than once per 24 hours. I wanted this script to store the last visit time in a table against the user ID in a ...
2
votes
0answers
26 views

Verify OpenSSL RSA signature (PHP) with .NET (VB)

I would like to achieve something I believe is pretty standard: A) My VB.NET client (ideally targetting Framework 4.0) sends a text string to my Apache/PHP Server via an HTTPS POST request. B) My ...
2
votes
0answers
24 views

WordPress plugin for shipping calculation

I am writing a WordPress plugin that allows shipping calculation on the product page. Originally, shipping calculation is only available in the cart. To calculate shipping costs on product page, ...