Questions tagged [php]

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

370 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
1k views

Multi-query PHP Parser for SQL files

I have an external project, which needs to run an SQL file containing multiple SQL queries (a bit like mysqldump, if you like, but is user-created, with any kind of SQL statement/definition). PHP ...
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
49 views

upload multiple images and resize

I'm written PHP code to upload multiple images to server. this function process maximum 10 images at one time and if the image width or height bigger than 2000px it will be resize , but the code is ...
4
votes
0answers
53 views

Enables markup to instantiate objects, call methods, and generate HTML

I'm looking for a code review for the package PXP. https://github.com/hxtree/PXP/ PXP enables markup to instantiate objects, call methods, and generate HTML. It works similar to a server-side ...
4
votes
0answers
58 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
1answer
189 views

OO and non-OO usage of Mysqli

I'm starting to learn the object oriented aspect of PHP. In this regard I made a small "exercise" of sorts "translating" one of my PHP functions into OO mode of PHP. I'm asking if there are there any ...
4
votes
0answers
71 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
397 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 files -...
4
votes
0answers
218 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
207 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 ...
4
votes
0answers
44k views

Building a “LIKE” query in Yii2

This code is making an SQL query. The last andWhere() method adds a LIKE condition with one percentage sign at the right. I'm ...
4
votes
1answer
94 views

File read/write methods

I'm using some simple files for caching and some basic user data. I was first just using file_put_contens and file_get_contents, ...
3
votes
0answers
23 views

Add pivot data from the same pivot model

My project has thee models Cart, Order and Product Cart ...
3
votes
0answers
51 views

Mysql PDO Wrapper that throws Unique Constraint Exception

The main reasoning behind this PDO wrapper, is that I find myself using unique constraints quite frequently in my designs, and I have ...
3
votes
1answer
70 views

Securely upload multiple image files with PHP

I am working on script to a upload image files Securely. can anyone please review my code and suggest improvements on security. ...
3
votes
1answer
54 views

Laravel Scope get request data/param

I want to pass the param from the request on the scope method in the model and serve it as json to be rendered by select2. Which is better? 1. Pass request from the controller like this controller: <...
3
votes
1answer
54 views

Custom exception for each invalid input value

I have backend project in which there's own "parent-to-all exception" exists, something like this (also I have InvalidArgumentException derived from this exception): ...
3
votes
0answers
77 views

Symfony 4 translate Entity fields

I have been developing multilanguage website based on Symfony4. Structure of one of the tables: ...
3
votes
0answers
323 views

Product Filters wordpress plugin: implement single responsibility principle for elements classes

Plugin is a small editor that allows to create a filter such as a price slider, checkboxes of "brands", a drop-down of "seasons". An example of how plugin work can be seen on page: http://demo-...
3
votes
0answers
54 views

Divide / Split single file .php into clean code parts

I wrote a page with Laravel to manage projects with Scrumpoker through blade syntax with controllers, models and Vue.js. My problem is that I wrote the actual Scrumpoker in a single file.php file and ...
3
votes
0answers
39 views

Adapter pattern to support multiple file storage systems

I am just getting in to following design patterns. I have create a class that allows for performing a couple operations on different remote storage systems: drive, dropbox, .etc (I call these ...
3
votes
0answers
822 views

Symfony 4 controller with multiple forms

I have several pages in my app that have multiple forms. In this example, the 'account' page has 2 forms: allowing the user to change their password allowing the user to contact support I am new to ...
3
votes
0answers
91 views

PayPal Checkout API with PHP - Sending and retrieving additional data safely

I am learning to use the new API version of Paypal, and I have some doubts. Note: I've tried this on https://www.sandbox.paypal.com and it works, I have not done the tests on Live. onApprove: I ...
3
votes
0answers
344 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 ...
3
votes
2answers
129 views

Sanitize vars on form submit

I have this code and I would like to know if I filtered my code correctly. I am practicing my security coding for a system that I am working on and I would like to know if I am doing it the right way. ...
3
votes
0answers
35 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
28 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
2answers
173 views

Simple single-file PHP login system

This is something that I initially came up with to protect a bunch of scripts on my personal webserver, but am now planning on using with a few public projects too. ...
3
votes
0answers
371 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
39 views

Dependency Container

I'm currently creating my own microframework for learning purpose and I want to make it more powerful by providing a way to register classes and instantiate them (once) only when needed. So here is my ...
3
votes
0answers
1k 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

My implementation of repository pattern in Laravel 5.6

...
3
votes
0answers
68 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
55 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
575 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
56 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
93 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
472 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
132 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 ...
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
52 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
71 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
1k 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
70 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
1k views

Add values to a multidimensional array of unknown depth

I have the following class: ...
3
votes
0answers
84 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
15k 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
669 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
558 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 ...

1
2 3 4 5
8