r/PHPhelp

Directory structure for vanilla PHP blog/project CMS

Can you take a look if this directory structure is good for vanilla PHP blog/project CMS ? I was curious if I can build my own CMS for blog posts, blog archives and projects. Before I had a WordPress site with those features which I built using Underscores. Please see here directory structure

reddit.com
u/810311 — 2 days ago

What should I do to increase the speed of my development ?

I have already built a enterprise system with capabilities mentioned below. Please read the complete details and suggest me what can I do to speed up the development ? How can I use AI further to create more deterministic codes

[ Do not ask for github link. This is not an open source project. This is my internal system ]

PrestoFox is a business application System with a collection of components needed to build applications of any complexity. These components work together in PrestoFox to create a strong foundation for the application that gets built on top of it. It is based on modular monolithic MVC architecture both in backend and frontend.

It is built with MIT-licensed technology like Symfony (PHP) at the backend and Quasar (Vue Js) at the front end. It uses a PostgreSQL database and makes use of the latest

GraphQL technology to build APIs. Companies can build applications in many flavors

  • SPAs (Single Page App)
  • SSR (Server-side Rendered App) (+ optional PWA client takeover)
  • PWAs (Progressive Web App)
  • BEX (Browser Extension)
  • Mobile Apps (Android, iOS, ...) through Cordova or Capacitor
  • Multi-platform Desktop Apps (using Electron)

It has code generator whose core purpose to create complete application modules end to end. It does the following

  • Generate Bundle / Module
  • Generate Doctrine entity
  • Add Validations when the property is not null
  • Add picklist based relationship using wizard
  • Add relationship like OneToOne , OneToMany , ManyToOne, ManyToMany using wizard
  • Generate Database migration
  • Execute Migration
  • Generate GraphQL schema
  • Generate GraphQL OutputType
  • Generate GraphQL InputType
  • Generate Permission
  • Generate Frontend configuration
  • Generate Admin UI components

It has crud capabilities like

  • Full CRUD (list, create, read, update, delete)
  • Single Record Update Only (update form only)
  • Single Record View and Update Only (read, update)
  • Multiple Record Update Only (list, read, update)
  • View Only (list and show only)

It also has separate generator for

  • Command
  • Job Scheduling
  • Data Populator
  • Notification
  • Picklist

System itself have the following implemented

  • Authentication and Authorization module
  • Attachment module
  • Queue System , Cron Job , Job Scheduling and Job Logs
  • Data History , Data Revision , Data Revert , Data Validation
  • Error Logging
  • HealthChecker module
  • Tax module
  • Export module
  • Locale Data module
  • Notification module with all channels like Email, SMS, WhatsApp, etc
  • Multitenancy
  • Document Sequencing Bundle
  • Invoice module
  • Comment module
  • Address module
  • Employee module
  • Custom Field module
  • Entity Link module
  • Real Time update module based on mercure
  • User Meta Data module
  • User and Organization Preferences
  • Security Related implementations and API Call limiting

Along with it, It has entity field collection can be added to Doctrine entity file via implements and Use ___Trait approach. These are the list of all the entity collections

  • Address Aware
  • Currency Aware
  • Date Aware
  • Single Email Aware
  • Multiple Email Aware
  • Entity Aware
  • Lat Long Aware
  • Meta Data Aware
  • Organization Aware
  • Owner Aware
  • Space Aware
  • Person Aware
  • Single Phone Number Aware
  • Multiple Phone Number Aware
  • Team Aware
  • User Aware
  • User Meta Data Aware
  • Custom Field Aware
  • Tax Aware
  • Sub Total Aware

I also has events built in for each Entity. The events are

  • onPreRemove
  • onPostRemove
  • onPreCreate
  • onPostCreate
  • onPreUpdate
  • onPostUpdate

On the frontend side , I has following implementation

  • UI controls mapped for each datatype of the entity .
  • Well designed minimalist Admin UI.
  • Flexible data grids and filters system.
  • Role based menu management
  • UI for desktop and mobile menu
  • Reusable Context menu Component
  • Reusable Toolbar Component
  • Controls for Single , Multiple Phone Numbers
  • Advance dropdown menu where one can 1) Search records 2) See all records in grid 3) Create new record on fly
  • Translation system
  • Multiple screen layouts like Main,Header Only,Full Screen, Empty , Auth etc
  • Vue Mixins for standard functionality around like 1) CRUD 2) Grid 3) Layout 4) Forms
  • Common Services like Config, Data Encrypt and Decrypt , Display Formats , Notifications , Page loading , permission, utility etc
reddit.com
u/sachingkk — 4 days ago

weird behavior in including files

i have a weird problem in including files in php, i have a functions.php file in a folder and a Router in the index.php file, when i include thefunctions.php in the index.php, all the other pages that rely on it get broken, the variables become empty and the functions no longer work, when i dont include it in the index.php file all the other pages function normally

i include my files in all pages in this way

require_once($_SERVER["DOCUMENT_ROOT"] . "/src/logic/functions.php");

my other pages are in /src/pages/

i have tried all ways of including the file but i keep getting the same problem, i need to include the functions.php in the index file to use some of its functions.

i do have a declare(strict_types=1) in the index file if that affects it

Any help will be appreciated thanks.

reddit.com
u/Available_Hippo4035 — 6 days ago

file not being deleted after its expiry time passes

Hello, im trying to make a rate limiting function that prevent users from using specific forms when they reach a certain threshold and the limit will get reset after a certain amount of time, when a user submits a request, a file with their ip will get created into a cache folder and the amount of requests is inside the file, the rate limiting works except the file doesnt get deleted after the specified amount of time passes, any help will be appreciated. Thanks!

rate_limiter.php

<?php
ignore_user_abort(true);
//Get the user IP
function getIP() {
$ip = null;
if(!empty($_SERVER["REMOTE_ADDR"])) {
$ip = $_SERVER["REMOTE_ADDR"];
} elseif(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}

return $ip;
}

function rate_limit($ip, $requests_limit, $limit_expiry) {
$start_time = null;
$reached_limit = null;
$amount_requests = 1;
$file_name = __DIR__ . "/cache/ratelimit-" . $ip;
$file_name = rtrim($file_name);
if(!file_exists($file_name)) {
global $start_time;
$start_time = time();
$fp = fopen($file_name, "w+") or die("An error occured");
fwrite($fp, $amount_requests) or die("Failed to write into file");
fclose($fp);
} elseif(file_exists($file_name)) {
$fp = fopen($file_name, "r+") or die("Failed to read file");
$new_amount_requests = file_get_contents($file_name);
if($new_amount_requests >= $requests_limit) {
global $reached_limit;
echo "<script>alert('You have been rate limited!')</script>";
$reached_limit = true;
header("Location: /", 423, true);
} elseif(!$reached_limit) {
$new_amount_requests++;
ftruncate($fp, 0);
fwrite($fp, $new_amount_requests) or die("Failed to write amount of requests");
}
}

if(file_exists($file_name) && time() - $start_time >= time() + $limit_expiry) {
unlink($file_name);
}




}

?>

index.php

<?php
ignore_user_abort(true);
require_once("rate_limiter.php");

if(isset($_POST["submit"])) {
$ip_Addr = getIP();
rate_limit($ip_Addr, 3, 60);
echo $_POST["text"];
}

?>
reddit.com
u/Available_Hippo4035 — 8 days ago

Composer installation fails with "certificate verify failed" PHP beginner

Hi everyone,

I’m a beginner in PHP and I’m currently trying to install Composer on Windows with WampServer.

I keep getting an SSL certificate verification error during the installation (certificate verify failed / Failed to enable crypto), and I’m not sure how to fix it.

I’ve already checked my php.ini file, but as a beginner I may be missing something important.

Could anyone help me understand what’s causing this issue and how to solve it? Any simple explanation would be greatly appreciated.

Thank you in advance!

reddit.com
u/Same_Development1120 — 10 days ago

hi guys, I need to ask you something urgently about ajax

anyways, I'm having a hard time integrating guide_ajax into php, as well as all the ajax stuff that was on youtube or somewhere else, anyway, I really need help right now, so please help me figure out how to connect all of this, etc.

i making my yt 2012 frontend project, called: oldpipe

and also, my other youtube revival project too

reddit.com
u/Expensive_Fly_6116 — 9 days ago

Two different versions of an app (free/paid)

This might be a basic question, but I've never done this before...

How do you handle a situation where you want to generate two different versions of an app (free/paid) from a single version of the code? Claude tells me, “Use separate conditional blocks for each version, and then use Phing to remove the conditional blocks for each version of the code – for example, use replacergexp in the filterchain with something like

<regexp pattern="// @@IF_PAID_START@@.*?// @@IF_PAID_END@@"

Is there a more sophisticated way to do this? In any case, I want the free version to give no indication that a paid version exists.

reddit.com
u/Mastodont_XXX — 12 days ago

Anyone Have a Soft Copy of PHP & MySQL: Server-Side Web Development by Jon Duckett?

Hi everyone,

I'm currently learning PHP and MySQL and I'm looking for a soft copy (PDF/ebook) of PHP & MySQL: Server-Side Web Development by Jon Duckett.

If anyone has a copy they're willing to share, I'd really appreciate the help.

Thanks in advance!

reddit.com
u/NoCode2388 — 11 days ago
▲ 4 r/PHPhelp+1 crossposts

Old Developer Went AWOL so I Inherited a Wordpress CRM on Bluehost, How Do I Fix the Code?

Hi.

For context, my relatives hired an offshore developer via Upwork to create a Wordpress CRM for our mom & pop business.

I'm a seasoned web developer with experience in hosting MariaDB, PostgreSQL, React, Vue, Svelte, and other apps in Docker and in various cloud providers.

However, I don't have the same experience with Bluehost "ClickOps" and PHP in general with Wordpress.

Recently, a bug surfaced in the CRM that's impeding core business functionality that my relatives can't work around.

We tried to contact the maintainer of the website but they won't answer our calls or emails for 2+ months.

Therefore, as the IT guy in our family, I decided to take it upon myself to fix the issue.

I've got the credentials to the Bluehost account where the domain & actual Wordpress site is being hosted.

Can anyone point me to resources on how to "download" the codebase into my own local machine and push changes to the production site?

As far as I know, the Wordpress site is not versioned by git.

Any help would be appreciated.

reddit.com
u/GovernmentOnly8636 — 12 days ago