PHP Reddit – Telegram
PHP Reddit
34 subscribers
292 photos
37 videos
24.9K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
should i learn php or javanoscript after learning html and css?

I think I only have around 6 months left to learn web development before our Capstone 1 project. I used to study coding on and off, but I only reached the basics of JavaScript. I eventually lost motivation and stopped learning, so I forgot everything and had to start from scratch. Should I study PHP right after HTML and CSS so I can get an idea of backend development and build a functional system? I'm also thinking about hosting when the time comes for our capstone — it might be expensive if we use a backend language that isn’t well-supported. I also noticed that the roadmaps involving JavaScript and React would take much longer to learn, and they don't focus much on the backend. Maybe you have some suggestions. Thank you in advance.

https://redd.it/1k88o0k
@r_php
Sylius framework for non e-commerce projects - bad idea?

Currently I'm trying to decide which frameworks to choose for my freelance projects. I need an e-commerce one and a regular one for just simple appointment system type of pages. For an e-commerce I will try the Sylius framework, it looks pretty decent and fulfils all my needs.

Now for the regular pages - I can't decide between OctoberCMS and a few others, but I wonder why not use the same one - Sylius. Just without all the e-commerce features it has to offer.

Has anyone tried it? I wonder if it makes sense and if there is any drawbacks if I decide to use it this way. From the first look it's pretty neat with all the user management features, nice looking admin panel, API etc. Also I love Symfony. It looks like a pretty decent framework to work on even when I don't need to build an e-commerce.

Of course I would need to disable all the e-commerce packages, so my question is - can I do it cleanly? Does it perform well?

https://redd.it/1k8dp90
@r_php
Finally Dockerized my Laravel based application with a minimal setup.

Hello All,

Quite often while sharing my githu repo for the Laravel based application I have been working on, I got asked if I could provide Dockerfile for the application.

So, by following tutorials and other resources online I have made Dockerfile and docker-compose.yml file so that it can easily be run inside docker.

I tried to follow official Docker page for Laravel setup, but the Dockerfile and docker-compose.yml files were too complicated. I just wanted a minimal setup, so that anyone with Docker could install the app easily and get a feel of it.

https://github.com/oitcode/samarium

It is a minimal setup with Apache server and MySql database. Docker installation instructions are in the README of github repo. Would appreciate if anyone looked into it and provided feedbacks.

I am planning to improve the docker setup, but for now, relieved that a minimal setup is working. There was many good things to learn while containerizing/dockerizing the app. That itself was a good experience. Hoping to improve further on this in future.

Thanks all.

https://redd.it/1k8eszh
@r_php
My new installable PHP Sandbox

Hello,

I have created a PHP Sandbox with NativePHP that I would like to share with everyone. It uses Electron to wrap the whole app and make it executable from your OS.

It is called PHP Dune, and it is available as Open Source in GitHub, or you can download the package for Windows, Mac and Linux.

This is the website: https://phpdune.salmonjump.com/
And this is the link to the repo: https://github.com/pabloFdz/PHPDune

I hope you find it useful!

https://redd.it/1k8gvha
@r_php
Questioning about PasswordStrength Constraint

I would like to use the Constraint PasswordStrength to validate that the user passwords are strong enough. Ideally I would like to not create my custom PasswordStrengthValidator, but I also would like to return custom messages to help user to create a correct password if their are not strong enough (e.g tell them that the password needs uppercase, lowercase, special chars, and a given length).

But regarding the PasswordStrengthValidator I can't really understand what are the rules behind each levels


Here is the method that validate the strength in symfony/validator

    public static function estimateStrength(#\SensitiveParameter string $password): int
    {
        if (!$length = \strlen($password)) {
            return PasswordStrength::STRENGTHVERYWEAK;
        }
        $password = countchars($password, 1);
        $chars = \count($password);

        $control = $digit = $upper = $lower = $symbol = $other = 0;
        foreach ($password as $chr => $count) {
            match (true) {
                $chr < 32 || 127 === $chr => $control = 33,
                48 <= $chr && $chr <= 57 => $digit = 10,
                65 <= $chr && $chr <= 90 => $upper = 26,
                97 <= $chr && $chr <= 122 => $lower = 26,
                128 <= $chr => $other = 128,
                default => $symbol = 33,
            };
        }

        $pool = $lower + $upper + $digit + $symbol + $control + $other;
        $entropy = $chars * log($pool, 2) + ($length - $chars) * log($chars, 2);

        return match (true) {
            $entropy >= 120 => PasswordStrength::STRENGTH
VERYSTRONG,
            $entropy >= 100 => PasswordStrength::STRENGTH
STRONG,
            $entropy >= 80 => PasswordStrength::STRENGTHMEDIUM,
            $entropy >= 60 => PasswordStrength::STRENGTH
WEAK,
            default => PasswordStrength::STRENGTHVERYWEAK,
        };
    }
    public static function estimateStrength(#\SensitiveParameter string $password): int
    {
        if (!$length = \strlen($password)) {
            return PasswordStrength::STRENGTHVERYWEAK;
        }
        $password = countchars($password, 1);
        $chars = \count($password);


        $control = $digit = $upper = $lower = $symbol = $other = 0;
        foreach ($password as $chr => $count) {
            match (true) {
                $chr < 32 || 127 === $chr => $control = 33,
                48 <= $chr && $chr <= 57 => $digit = 10,
                65 <= $chr && $chr <= 90 => $upper = 26,
                97 <= $chr && $chr <= 122 => $lower = 26,
                128 <= $chr => $other = 128,
                default => $symbol = 33,
            };
        }


        $pool = $lower + $upper + $digit + $symbol + $control + $other;
        $entropy = $chars * log($pool, 2) + ($length - $chars) * log($chars, 2);


        return match (true) {
            $entropy >= 120 => PasswordStrength::STRENGTH
VERYSTRONG,
            $entropy >= 100 => PasswordStrength::STRENGTH
STRONG,
            $entropy >= 80 => PasswordStrength::STRENGTHMEDIUM,
            $entropy >= 60 => PasswordStrength::STRENGTH
WEAK,
            default => PasswordStrength::STRENGTHVERYWEAK,
        };
    }



So imagining I would like to use PasswordStrength Constraint with STRENGTH_MEDIUM what should be the prerequisite of a correct password ?

https://redd.it/1k8mzcf
@r_php
Requesting feedback on my SQL querybuilder

Throughout the years, i've developed a framework i use for personal (sometimes professional) projects. It suits most of my needs for a back-end/microservice framework, but i've grown particulairly fond of my querybuilder/ORM.

Here is the public repo: https://github.com/Sentience-Framework/sentience-v2/

For a quick look at some examples: https://github.com/Sentience-Framework/sentience-v2/blob/main/src/controllers/ExampleController.php

Database documentation: https://github.com/Sentience-Framework/sentience-v2/blob/main/documentation/documents/database.md


The feedback i'm mostly interested in, is which features you'd like to see added to the querybuilder. Security / performance / coding principle conceirns are always welcome ofcourse :)

https://redd.it/1k8ojj0
@r_php
CORS issue on PHP backend hosted on Hostinger (some APIs work in browser, some don't

Hey everyone,
I'm facing a strange CORS issue and need some help.

I have a PHP backend hosted on Hostinger.
When I test my APIs with Postman, everything works fine.
When I test from my frontend (browser), some APIs work — but some others give CORS errors on windows but all work when use Linux

After some research, I realized Postman doesn't care about CORS, but browsers do.

https://redd.it/1k8oai4
@r_php
Weekly /r/Laravel Help Thread

Ask your Laravel help questions here. To improve your chances of getting an answer from the community, here are some tips:

What steps have you taken so far?
What have you tried from the documentation?
Did you provide any error messages you are getting?
Are you able to provide instructions to replicate the issue?
Did you provide a code example?
Please don't post a screenshot of your code. Use the code block in the Reddit text editor and ensure it's formatted correctly.

For more immediate support, you can ask in the official Laravel Discord.

Thanks and welcome to the r/Laravel community!

https://redd.it/1k98qs4
@r_php
Would you prefer namespace-level privacy?

In some programming languages like Java you get more flexibility in your levels of privacy e.g.- a “protected” method can be accessed by any class in the same “package” (in PHP we use the term “namespace” instead of package but it’s the same idea).

Also a whole class itself in Java can be declared protected or private and this will affect its visibility in useful, subtle ways.

In PHP it’s possible to use attributes combined with static analysis to simulate this but it’s not as desirable as having the features built into the language.
I’m a real stickler for the defensive style of programming so that only certain classes can see/access other classes. Also, it’s good for DDD when one class can see the internal properties of another class in the same namespace (e.g.- for persistence or presentation) without needing lots of “getter” methods.

I’m interested in hearing the thoughts of the wider PHP community on this.

https://redd.it/1k9ccu0
@r_php
Question about TwigMarkup Extra bundle and league/commonmark

I am trying to put together a document from markup using the TwigExtra Markdown package with league/commonmark for the trasnpiler. I have several tables that need to be implemented from the markdown, and I need to tell commonmark to use the TableExtension. However, I cannot find a suitable piece of documentation to even start trying to figure out how to configure this. Anybody have any solutions? Thank you.

https://redd.it/1k9h798
@r_php
Weekly Ask Anything Thread

Feel free to ask any questions you think may not warrant a post. Asking for help here is also fine.

https://redd.it/1k9lvaa
@r_php
Weekly help thread

Hey there!

This subreddit isn't meant for help threads, though there's one exception to the rule: in this thread you can ask anything you want PHP related, someone will probably be able to help you out!

https://redd.it/1k9ojug
@r_php
Interviewing for a PHP & Etc. Developer without knowledge?

To cut the story short, I have a business and recently started looking for new developers for my site. My site is mostly coded in PHP, Laravel MVC, and SQL. I used to have a developer, however we are no longer in good terms anymore.

How would I go about hiring a new developer? I have no idea anything about PHP and everything, and I definitely don’t want to get ripped off by people just claiming to know PHP and such.

Note: Sorry if this is the wrong place to ask for this. Help redirect myself to the right resources. TIA!

https://redd.it/1k9pd6s
@r_php
Distribute tests across multiple GitHub Action workers

In collaboration with u/localheinz I've build a small \#github \#actions utility workflow. It describes how to segment a projects phpunit overall test-suite and distribute the load over parallel running github actions jobs


https://github.com/staabm/phpunit-github-action-matrix

https://redd.it/1k9rdnk
@r_php