Questions tagged [php]
PHP is a widely-used, general-purpose scripting language that is especially suited for web development.
363
questions with no upvoted or accepted answers
6
votes
0answers
51 views
Wrapper for Google_Service_Calendar as a Symfony service
My app interacts with Google Calendar. This Service wraps Google_Service_Calendar:
...
4
votes
0answers
72 views
Enables markup to instantiate objects, call methods, and generate HTML
I created this package PXP.
PXP enables markup to instantiate objects, call methods, and generate
HTML. It works similar to a server-side templating engine, but rather
than enforcing braces it ...
4
votes
0answers
74 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
428 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
220 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
210 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
1answer
97 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
1answer
63 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
1answer
121 views
Implementing Decorator Pattern
Context
I'm looking into design patterns. My first try is using the Decorator Pattern.
Question:
Is there another (maybe standard) approach to applying modifications in a decorator other than ...
3
votes
0answers
85 views
Symfony 4 translate Entity fields
I have been developing multilanguage website based on Symfony4. Structure of one of the tables:
...
3
votes
0answers
352 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
57 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
48 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
104 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
150 views
Codeigniter 3 loading models in a different way
I'm currently building an application that uses the same models in different controllers. Instead of using the normal way, being loading the model in the controller I've build a "core controller" (<...
3
votes
0answers
428 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
141 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
29 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
186 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
411 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
41 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
2k views
3
votes
0answers
71 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
57 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
602 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
59 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
98 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
1answer
2k views
Separate areacode from phone number string with MySQL Database
I have a database with 5000 entries of local area codes to separate the area code from a phone number string. I'm not sure if the code
I use is the fastest way to solve these job.
I shrink the ...
3
votes
0answers
489 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
140 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
72 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
39 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
3k views
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
3
votes
0answers
85 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
696 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 ...
3
votes
0answers
181 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
759 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
996 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
853 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
629 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
675 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 ...