r/PHPhelp • • Aug 20 '23

How Do I Make "Real Time" Updates?

11 Upvotes

I'm building an web app and up to this point I've been using mostly PHP in order to achieve this. The problem I'm trying to solve right now may not involve PHP--or a majority PHP, but I'm looking for direction on how to develop this.

THE BASICS:

The webapp is a simple "customer makes orders and then that data is sent to the database" type of process.

THE PROBLEM:

I have the check-out page created, the database created and most of the backend figured out.

So when the customer makes an order on teh check-out page, teh data is sent to the database.

There is going to be a monitor where people are able to see the orders as they are made in real time.

So once the customer presses the " make your order " button I would like that order with all the associated data to appear on the monitor. And I want this to happen without having to refresh the page. How would I be able to accomplish this (in big picture terms)?


r/PHPhelp • • Jun 16 '23

Is Working With API's Supposed To Be This Stressful Or Am I Doing It Wrong?

11 Upvotes

I'm connecting to an API in my PHP application to gather data and make sense of that data by traversing through it. The most frustrating part is that the data is structured in a very complex way (arrays with more than 5 dimensions) and I don't even have a reference as to how to access what.

So I've just had to console log the results of all the GET requests and then copy and paste that into text editor so that I can see which opening bracket matches with which closing bracket and then count the number of dimensions.

Also some of the GET requests are generating more than 8,000 results and I don't even know how to stop it because I don't know which exact dimension of the array that is occuring in. Some of the requests are resulting in endless loops too.

Am I going about this the wrong way? Surely it cannot be this stressful? I feel like I'm in an ocean of strings with no compass.

Is the only way to overcome this is by using a debugger with breakpoints? I've never used one before, I've always debugged the simple old school way (console logging return statements and variables).


r/PHPhelp • • Feb 09 '23

Ideas to tackle heisenbug

11 Upvotes

I've a fairly complex set up I didn't create that includes Symfony/4.4, PHP/8.1, Xdebug/3, PhpUnit, Nginx, PostgreSQL and Docker, running on Kubuntu 22.04 LTS. Xdebug is set up to always connect with a 20 ms timeout.

There's an application test that always passes, except when PhpStorm is listening for debugging connections. In that case, it always fails, in the same spot, The test uses the builtin client to invoke an API end-point, and the end-point throws an exception about Doctrine finding non persisted entities due to a clear() call on the object manager.

That's literally the only thing I need to make the test fail: click the "Start Listening for PHP Debug Connections" button in PhpStorm. I don't even need to set breakpoints. It's 100% reproducible. It only happens on my machine.

Do you have any wild guess of what could possibly be causing this?


r/PHPhelp • • Jan 16 '23

Control which helper.php is loaded first in a laravel project

11 Upvotes

Hello,

I am maintaining multiple packages which publish via ./src/helper.php some global helper methods. Therefore I have in the composer.json inside the packages defined:

    "autoload": {
        "files": [
            "./src/helpers.php"
        ],
    } 

However, inside my Laravel projects, I want to overwrite some of these helpers, therefore I would like that app/helper.php is loaded before vendor/mypackage/src/helper.php

in the laravel project, I have defined:

    "autoload": {
        "files": [
            "./app/helpers.php"
        ],

So is there a way to tell composer to load the app/helper.php before loading any other global file?

A concrete example I am trying to override would be this.

In my package for testing (and as a fallback to avoid crashes) purposes I have defined:

if (!function_exists('getEnvironment')) {
    function getEnvironment(): string
    {
        return config('wd.logging.environment', 'DEFAULT_ENV');
    }
}

and in my project I need to overwrite it with this function (this function should be used in production):

if (!function_exists('getEnvironment')) {
    function getEnvironment(): string
    {
        return Auth::user()
            ? getSetting(Auth::user()->client->settings, Setting::KEY_SHORT_CODE)
            : null;
    }
}

r/PHPhelp • • Dec 21 '22

Feedback about fresh open source project

11 Upvotes

Hey community!

I hope it is okay to ask this here. I am working on my first "serious" open source project in my free time which I want to tag with version 1.0 soon and share it "officially" with others: https://github.com/leepeuker/movary

I would love to hear other people opinions on what I could improve there, like is the README understandable or is the project structure okay? I am afraid I am maybe missing some things I cannot see or exprience myself. Any feedback appreciated :)


r/PHPhelp • • Dec 03 '22

Is a framework necessary to create a PHP project?

11 Upvotes

I understand that a framework can help me structure my project and give it security. I also understand that if you don't know how to use the framework well, it can take you more time to make a project than to do it manually, but leaving that aside and assuming that we know how to use the framework (example: symfony, laravel...), professionally for your own personal project, is it better to do it from scratch, or using what was mentioned above?

Really the intrigue that I have is if using the framework is equal to more security, or is equal to speeding up the process of creating the project.

So I ask these questions:

Using a framework equals more security? Can we have the same security doing it from 0? Is it worth using a framework even knowing that we are not the owner of all the code?


r/PHPhelp • • Dec 02 '22

Logic behind strtotime()

11 Upvotes

Is there a good read explaining the intricate logic behind PHP's strtotime() fucntion? I also would be happy to see the source code of this function but I cannot do so in github (so novice).

I mean, I write strtotime($date . "+1 day"); and it works. This is hilarious. I can parse Ymd, dmY formats into string. start of string is a number rest is English statement, and it does the job. Like a magic.

If I were asked to implement this logic in an interview, I would fail most probably :)


r/PHPhelp • • Nov 30 '22

Atom editor being retired - new editor recs?

11 Upvotes

Sorry if this is a low effort post.

With Atom being discontinued, what editor should I move to? I mostly do PHP, CakePHP, shell scripting, text file editing, python, HTML, JS. (If I do anything like Java I use Eclipse.) Some features important to me are multiple tabs, directory browsing, and remote editing via sftp/ftp connection.

Any recs?


r/PHPhelp • • Sep 28 '22

Solved Is there an equivalent to "console.log" (from JS) in PHP?

11 Upvotes

Hi all,

I'm coming from the world of Javascript (fullstack) and I use console.log values to see what's going on within the program I am working on (eg. if a certain value is what you expect it to be) and to test how far in the script you've gotten.

Is there an equivalent in PHP, or some tips and tricks in terms of how to watch if certain values are acting in how you need them to?

I have been using something like die(var_dump(VAR); which worked fine when things were really simple - but I am not finding it effective now that the programs have become bigger.

I've also been echoing certain things - but again, not always a reliable way as I don't always see the echo on the screen.

Right now for example, I want to watch how the $_SERVER values change to see if my post values are working or not.


r/PHPhelp • • Sep 27 '22

Solved Is making parallel SQL queries possible with PHP?

11 Upvotes

I bulk delete Reddit comments using Redact which also supports Twitter, Discord, Instagram, and data brokers.

groovy boat outgoing coordinated aspiring crayon encouraging existence sense nose


r/PHPhelp • • Aug 07 '22

Best php extension for vs code?

11 Upvotes

I switched from vscode + intelephense to phpstorm and i find it reeeeaaaally hard to go back because of all of the functionality that storm offers

However, i love vscodes snappiness and ease of use that phpstorm will never match

Is there any way out? How do I combine both? Im willing to pay for an extension just to get best of both worlds


r/PHPhelp • • Dec 14 '21

Solved The easiest way to learn Object Oriented Php?

11 Upvotes

Do anyone know any good guides or videos explaining how to start with object-oriented Php?

Thanks!


r/PHPhelp • • Oct 24 '21

PHP8 Attributes

11 Upvotes

I understand the syntax, I understand using reflection to examine=ine them, I understand they replace annotations.

Nowhere can I see reasoning for their use. I am old, granted, but the received wisdom of my day was that reflection was bad - using up clock cycles at run time to determine “something” about your code meant that the code design was inefficient. Determining that “something” at coding time meant greater run-time efficiency.

So, can someone ELI5 (or indeed, ELI95) the rationale / use case for using attributes?


r/PHPhelp • • Apr 25 '21

Solved How can using a grave accent (`) by mistake trigger shell_exec()?

11 Upvotes

$blah = array ( 'user_uuid' => $user_uuid, `user_id` => $clientId, 'country' => $country );

Warning: shell_exec() has been disabled for security reasons in......


r/PHPhelp • • Apr 17 '21

[Junior Developer] Can someone code-review my project?

11 Upvotes

I'm 16, junior developer who wants to get their first job as a Software Engineer. I was wondering if someone could code review my recent project, and give me feedback on how I can improve?

Thanks so anyone who checks this out, if you do find any bugs could you please use the issues area to report them. If you have any feature requests I can do which could help me improve, that's cool too.

https://github.com/ketchums/php-case-converter


r/PHPhelp • • Mar 21 '21

Best way to learn php?

11 Upvotes

Hey guys i have just started to learn backend. But I'm struggling real hard to get to know php/laravel. Please suggest me any beginner friendly book or yt channel or anything. Keep in mind i don't have any background in php/laravel or backend programming.


r/PHPhelp • • Mar 02 '21

18k+ lines of PR, HOW TO REVIEW AND MANAGE ?

11 Upvotes

In a new project, our management introduce sprint planning and code review process.

Around 4 devlopers working on different stories.

Problem arise when sprint about to end, everyone generating PR for their full week code change. I am supposed to review and merge them within the sprint.

I see two probability, We are doing things totally wrong Or I am not smart enough to manage such case.

Where you been in same pit ? Share your thoughts and possible solutions.

Thanks for reading.


r/PHPhelp • • Oct 24 '20

Solved What is the point of interfaces in PHP?

11 Upvotes

Are they there to remind you what to implement? Are methods they implement non-inheritable and so if you inherit from a class that uses interface functions you get everything but them? Someone enlighten me please because I simply don't see why else would anyone use these.


r/PHPhelp • • Sep 24 '20

Who is considered as a senior php developer?

11 Upvotes

I'm willing to apply for a senior developer position. But I'm not sure how to compare between junior and senior level php. I'm an individual programmer with 4 years of experience in Laravel and php.


r/PHPhelp • • Jun 16 '20

I create a git repo for learning oop with php

Thumbnail self.php
11 Upvotes

r/PHPhelp • • Jun 24 '18

When they say that PHP is not scalable, what do they actually mean?

11 Upvotes

r/PHPhelp • • Sep 16 '17

Tutorial on getting xdebug to work with phpstorm?

11 Upvotes

Is there a good tutorial on how to get xdebug to work with phpstorm for both local development and development on a remote dev server? I'm having trouble getting it to work properly with the validation script part.


r/PHPhelp • • Nov 15 '16

Wrote article on how to create thumbnails with PHP. Looking for feedback on the solution, things that could be improved / are obviously wrong?

11 Upvotes

Link to the article itself. http://pqina.nl/blog/creating-thumbnails-with-php

I've done some projects in PHP years ago and am wondering if I'm doing this correctly or if there's some obvious mistakes I'm making.


r/PHPhelp • • Dec 30 '14

Solved You can now mark posts as SOLVED in /r/PHPhelp

11 Upvotes

We've added the option to mark your question as SOLVED.

If someone answers your thread, please click the 'SOLVED?' link to mark the thread as solved.

http://i.imgur.com/cFKcAZo.png