10 September, 2024
Are `elf.h` structures packed?
Programing Coderfunda September 10, 2024 No comments
All data structures that the file format defines follow the
"natural" size and alignment guidelines for the relevant class.
If necessary, data structures contain explicit padding to ensure
4-byte alignment for 4-byte objects, to force structure sizes to
a multiple of 4, and so on.
But since aligment is implementation defined I imagine that is not a good
pratice suppose that the structures are allways packed.
For example, the following (pseudocode) can falls in some systems/compilers:
unsigned char e_ident[EI_NIDENT]; // Supposing that sizeof(unsigned char) == sizeof(uint8_t)
Elf32_Ehdr *ehdr;
// First read the e_ident
fread(e_ident, EI_NIDENT, 1, file_ptr);
// Now read the ELF header
if(e_ident[EI_CLASS] == ELFCLASS32){
ehdr = malloc(sizeof(Elf32_Ehdr));
memcpy(ehdr->e_ident, e_ident, EI_NIDENT);
fread(&(ehdr->e_type), sizeof(uint8_t), sizeof(Elf32_Ehdr) - (size_t)EI_NIDENT, file_ptr);
}
On negative answer for the main question, there is some portable way to ensure that elf.h structures are packed?
NOTE: I'm using the elf.h from musl.
API WOOCOMERCE (INSERT PRODUCT) - Whitespace on attributes (options)
Programing Coderfunda September 10, 2024 No comments
I'm uploading a product via api rest v3.
I have the problem loading attribute options
If I use a space option, it separates the terms.
If Gravina Di Catania loads, Gravina takes me then Di and then Catania
If I do the test on postman everything is ok
If I make the call via Php no.
how do i fix it?
I put double quotes in the string.
I used addslashes
i tried doing JSON ENCODE of options array
09 September, 2024
Does it cost money to read from aws s3 in Python?
Programing Coderfunda September 09, 2024 No comments
* Using s3fs to read a file
import s3fs
s3 = s3fs.S3FileSystem()
path = "s3://my-bucket/foo/bar.txt"
text = s3.read_text(path)
* Using s3fs to glob for files
import s3fs
s3 = s3fs.S3FileSystem()
bar = "s3://my-bucket/foo/*"
my_paths = s3.glob(bar)
* Reading a file with pandas
import pandas as pd
path = "s3://my-bucket/foo/bar.csv"
my_df = pd.read_csv(path)
Is someone getting charged money when I do any of these three things?
Don't undo what you haven't done. Avoid this subtle, but insidious little bug.
Programing Coderfunda September 09, 2024 No comments
Pest v3 Now Available
Programing Coderfunda September 09, 2024 No comments
Laravel Password Hashing With Salt
Programing Coderfunda September 09, 2024 No comments
Theo (t3dotgg) rage-baiting about Laravel without reading the docs
Programing Coderfunda September 09, 2024 No comments
https://t.co/l6yEb3qd50" / X
Okay so I watched his stream regarding Laravel, and he didn't put much effort to read the docs other than installation page and is already spreading negativity on Twitter/X regarding Laravel.
Any thoughts? Is Laravel docs that confusing for a beginner? submitted by /u/TastyInternet
[link] [comments]
08 September, 2024
Weekly /r/Laravel Help Thread
Programing Coderfunda September 08, 2024 No comments
* 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! submitted by /u/AutoModerator
[link] [comments]
nextjs google sign in
Programing Coderfunda September 08, 2024 No comments
right now I'm using nextAuth with a simple sign in to google, the process is opening console.cloud.google, and doing a few setups to get the GOOGLE_CLIENT_ID & GOOGLE_CLIENT_SECRET for getting permissions and once access is granted i would be able to modify,create folders,upload files & delete files/folders on my google drive
.
So my curiosities is, can i use other authentication libraries like clerk and lucia, to get a equivalent of GOOGLE_CLIENT_SECRET & GOOGLE_CLIENT_ID= in which can grant me access to my google account?
Hope my question makes sense to y'all
Why Postgres query is not using column in Index Condition but uses it in Filter condition
Programing Coderfunda September 08, 2024 No comments
Query:
SELECT
relevant_incidents_per_inventory_item.inventory_id,
tracker_id
FROM
relevant_incidents_per_inventory_item
JOIN
incident_tracker_details
ON
incident_tracker_details.incident_id = relevant_incidents_per_inventory_item.incident_id
WHERE
incident_tracker_details.company_id = :companyId
and incident_tracker_details.division_id = :divisionId
AND incident_tracker_details.value > 0
the index in use:
create index companyid_divisionId_incidentId_idx
on incident_tracker_details (company_id, division_id, incident_id)
where (value > 0) include (tracker_id);
the relevant_incidents_per_inventory_item does not have any relevant indexes and the table is very small (few hundreds of rows).
the actual query plan:
QUERY PLAN
Hash Join (cost=6901.58..6913.72 rows=1 width=8) (actual time=90.663..315.278 rows=522 loops=1)
Hash Cond: (incident_tracker_details.incident_id = relevant_incidents_per_inventory_item.incident_id)
-> Index Only Scan using companyid_divisionId_incidentId_idx on incident_tracker_details (cost=0.57..12.68 rows=6 width=16) (actual time=0.039..202.787 rows=246774 loops=1)
Index Cond: ((company_id = '777704491747470679'::bigint) AND (division_id = '777795770460846005'::bigint))
Heap Fetches: 124039
-> Hash (cost=6900.88..6900.88 rows=10 width=8) (actual time=86.704..86.709 rows=259 loops=1)
...not relevant part
Planning Time: 0.518 ms
Execution Time: 315.402 ms
Why is the "incident_id" not part of the Index Cond? this leads to retrieving all the rows under companyId, divisionId , and then the engine has to filter all the rows for those having incident_tracker_details.incident_id = relevant_incidents_per_inventory_item.incident_id
I expected to see all the columns used in the Index Condition, leading to fast retrieval of only the relevant data
SQL Server options to handle a large table, from the options listed below [closed]
Programing Coderfunda September 08, 2024 No comments
In order to scale the database, and for performance, I am considering the implementation partitioned tables, however, I keep reading about downsides. I wanted about your experiences and preferred approach between the options listed below, in the context of implementation ease, efficiency and subsequent maintenance:
* Partitioning table
* Indexed views
* Sharding
* Filtered indexes
* Partitioned views
* In-Memory OLTP
Sonatype Nexus OSS 3.69.0 Npm Issue
Programing Coderfunda September 08, 2024 No comments
For Maven and Docker, it is working fine.
But when it comes to npm, when I use the Nexus container with these image on my local machine without internet access, everything works as expected., However, when I run the same setup in another environment(aws ec2 with 8CPU,32GB RAM), also without internet access, I encounter issues with npm.
Specifically, npm takes about five minutes to retrieve a single package. The npm repository is a combination of both proxy(2k dependencies) and hosted repositories(7 artifacts), and I have artifacts stored in both. Despite this, I am seeing significant delays.
To install a single package, it is taking around 4-5 minutes. instead, 1-2 seconds in local.
I have confirmed that npm ping works correctly, and I can download npm artifacts using wget with no problems. However, npm install is where the issue occurs.
Could you please help me understand why this is happening and how it can be resolved?
In logs also I cannot see any., regarding delays.,
Configuration details:
some packages are in hosted repo, and some are in proxy cached, I kept negative cache to 0, and turned off it, meatda age and max component ages to -1., to use the caching always…No routing rules, and no firewalls enabled etc.
and this is the data that I am using in to create proxy npm repo:
{
“name”: “‘$npm_proxy_repository_name’”,
“online”: true,
“storage”: {
“blobStoreName”: “default”,
“strictContentTypeValidation”: true
},
“cleanup”: {
“policyNames”: [
“string”
]
},
“proxy”: {
“remoteUrl”: “
https://registry.npmjs.org”,
/> “contentMaxAge”: -1,
“metadataMaxAge”: -1
},
“negativeCache”: {
“enabled”: false,
“timeToLive”: 0
},
“httpClient”: {
“blocked”: false,
“autoBlock”: false,
“connection”: {
“retries”: 10,
“userAgentSuffix”: null,
“timeout”: 120,
“enableCircularRedirects”: false,
“enableCookies”: false,
“useTrustStore”: false
},
“authentication”: null
},
“routingRule”: “string”,
“replication”: {
“preemptivePullEnabled”: false,
“assetPathRegex”: “string”
},
“npm”: {
“removeNonCataloged”: false,
“removeQuarantined”: false
}
}
It’s a mysterious question still for us , why it is working in local mcahine, not in the aws server,
FYI, using the nexus server and npm client server, both are in same machine
07 September, 2024
Shiny downloadButton Status: Waiting for print(obj, file) execution before updating status
Programing Coderfunda September 07, 2024 No comments
I want to show the save status in the button by changing its label and icon.
I am using a downloadButton to allow the user to specify the location and file name. The report is an officer word document saved using print(obj, target).
The expected flow is:
* user clicks button
* button changes to "Saving..."
* file dialogue opens
* user selects file name/location
* r attempts to save the document
* if the save is successful (i.e., no errors)the button changes to "Saved"
* otherwise, button changes to "Save Failed"
The actual flow is:
* user clicks button
* button changes to "Saving..."
* file dialogue opens
* button changes to "Saved"
* user selects file name/location
* ...
The script does not wait for the user to select the file or see if the file saves correctly before changing the status to "Saved." In this case, the file is saving correctly, but the script has no way of knowing that before it prints to target, and it cannot print to target until the user provides the file name/location.
How may I revise this so that the status change is related to whether or not the file was saved without error?
library(shiny)
library(shinyjs)
library(officer)
ui
Are there any Laravel courses or reading materials where the author shares experiences that I can't find in the documentation?
Programing Coderfunda September 07, 2024 No comments
I recently bought Laracasts. It's nice, but it felt like documentation for lazy people. I already knew most of the things they covered just by reading the documentation (e.g., Filament).
Are there any courses or reading materials where people mainly share their experiences instead of simply rephrasing the documentation? I don't have a specific goal—I'm just looking to spend my spare time learning more about Laravel.
I often come across blog posts, videos, etc., for other programming languages like Java or Python that talks about real world problems and how those people solve those problems with the tools frameworks or languages provide, and I want to find similar content for Laravel or PHP in general.
but most of the content i find is already in the documentation.
For example, I’ve never seen much content on massively scaling Laravel queues.
note: this post is not intended to bash laracasts or say its not good or bash authors who wrote tutorials/make videos about laravel etc. i am simply looking for something different. submitted by /u/desiderkino
[link] [comments]
Kotlin spread operator for an array of functions does not satisfy Java Function... function argument definition
Programing Coderfunda September 07, 2024 No comments
Its current implementation:
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.groups.Tuple
fun checkObjectsHaveExactPropertyValue(
objectsList: List,
properties: Array,
expectedPropertyValue: R
) {
assertThat(objectsList)
.extracting(*properties)
.containsOnly(Tuple.tuple(expectedPropertyValue))
}
I want to be able to pass multiple property extractors as properties argument of my function. Then they are supplied to .extracting method.
And this is there code check and compilation error is:
Kotlin: None of the following functions can be called with the arguments supplied:
public open fun \ extracting(p0: Function\!): AbstractListAssert\! defined in org.assertj.core.api.ListAssert
public final fun extracting(vararg p0: Function\!): AbstractListAssert\! defined in org.assertj.core.api.ListAssert
public open fun extracting(vararg p0: String!): AbstractListAssert\! defined in org.assertj.core.api.ListAssert
public open fun extracting(p0: String!): AbstractListAssert\! defined in org.assertj.core.api.ListAssert
public open fun \ extracting(p0: ThrowingExtractor\!): AbstractListAssert\! defined in org.assertj.core.api.ListAssert
I don't see where I messed up.
I also tried following to debug typing:
* .extracting(properties[0], properties[1]) - compiles, function typing is correct, but not what I need
* different Iterable types (List, ArrayList, ...) - same error
* vararg properties: Function1 - same error
* properties: Array R> - same error
I expect there is correct typing for the argument of my function, so I can use overloaded method extracting(vararg Function!) defined in org.assertj.core.api.ListAssert.
Do you know someone who is helping PHP community and deserve sponsoring? (nominate)
Programing Coderfunda September 07, 2024 No comments
I want to give back love and sponsor couple developers, who grow our PHP community grow ❤️
Do you know someone like that? Let me know:
https://docs.google.com/forms/d/15sUIo3PnN4oLlaxKg6so8zYClrXjh8F3F2kzV5np3YU/ submitted by /u/Tomas_Votruba
[link] [comments]
Good vector database options with Laravel
Programing Coderfunda September 07, 2024 No comments
Now, with python there are so many vector db options (OS) LIKE Faiss, chroma db etc.
I can find good resources to learn about them as well. For example chromadb has great documentation.
Can anyone guide me which are options for Laravel? I don't want to have postgresql. Just because I have heard that the pgsql vector extension is not that performent compared to chroma or faiss submitted by /u/amitavroy
[link] [comments]
06 September, 2024
Learn to Fly with Laravel Reverb | Joe Dixon at Laracon US 2024 in Dallas, TX
Programing Coderfunda September 06, 2024 No comments
Prezet: Markdown Blogging for Laravel
Programing Coderfunda September 06, 2024 No comments
Let's build a Twitter clone with Livewire 3 & Laravel Reverb | 7 - Displaying Retweets
Programing Coderfunda September 06, 2024 No comments
Python Web scraping [D:websockets.client] > GET %s HTTP/1.1 [D:websockets.client] > %s: %s doesn't show all the results
Programing Coderfunda September 06, 2024 No comments
winrt::hresult_class_not_registered - AudioEffectDefinition with custom effect
Programing Coderfunda September 06, 2024 No comments
#include "MyAudioEffect.g.h"
auto effectName = winrt::name_of();
auto effect = winrt::Windows::Media::Effects::AudioEffectDefinition(effectName);
// Exception thrown
// winrt::hresult_class_not_registered
// 80040154 - Class not registered
I made a MRE:
https://github.com/tom-huntington/MRE_ClassNotRegistered
/>
To create the .idl .h .cpp files for the MyAudioEffect class, I used the template
-> Add -> New Item -> Custom Control (WinUI 3)
How do I register the class? Can someone fix my MRE please?
05 September, 2024
Why does emptyArray.every() return true in Javascript?
Programing Coderfunda September 05, 2024 No comments
Error with uno module when using unoconv for file conversion in Python: 'Cannot find a suitable pyuno library' despite venv setup
Programing Coderfunda September 05, 2024 No comments
I am doing this with Python and LibreOffice. I have installed everything, but it always gives me an error message with uno, although I have inhaled it. With Python, I actually always need venv.
I once asked ChatGPT for a Python script:
import subprocess
import os
def convert_pdf_to_odt(pdf_file):
# Überprüfen, ob die Datei existiert
if not os.path.exists(pdf_file):
print(f"Die Datei {pdf_file} wurde nicht gefunden.")
return
# Zielpfad: gleiche Datei mit der Endung .odt
output_file = os.path.splitext(pdf_file)[0] + '.odt'
try:
# Verwende unoconv, um das PDF in ODT zu konvertieren
subprocess.run(['unoconv', '-f', 'odt', pdf_file], check=True)
print(f"Erfolgreich konvertiert: {pdf_file} -> {output_file}")
except subprocess.CalledProcessError as e:
print(f"Fehler bei der Konvertierung: {e}")
if __name__ == "__main__":
# Beispiel-PDF-Datei (Pfad zur Datei anpassen)
pdf_file = '/home/ben/convert-commander/test/pdfs/Bild4.pdf'
# Konvertiere die PDF-Datei in ODT
convert_pdf_to_odt(pdf_file)
When executing, it gives me the error message:
unoconv: Cannot find a suitable pyuno library and python binary combination in /usr/lib/libreoffice
ERROR: No module named 'uno'
unoconv: Cannot find a suitable office installation on your system.
ERROR: Please locate your office installation and send your feedback to:
http://github.com/dagwieers/unoconv/issues
/> Fehler bei der Konvertierung: Command '['unoconv', '-f', 'odt', '/home/ben/convert-commander/test/pdfs/Bild4.pdf']' returned non-zero exit status 1.
As I said, I am in a venv
Can you help me?
Thanks!
(translated with deepl from german)
How to Locate and Interact with Elements Inside Shadow DOM and iframe in Selenium?
Programing Coderfunda September 05, 2024 No comments
HTML elements
How do I locate Shadow DOM (either CSS Selector, XPATH, etc.)?
The page I am trying to scrape is: scrape.do
P.S. I was aiming for the iframe in this way:
iframe = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, 'cf-chl-widget-3kwf9'))
)
When to use livewire by understanding jetstream ? (See description)
Programing Coderfunda September 05, 2024 No comments
When I looked at the views (here's the link: views folder), it seems like they’re mixing traditional Blade templates with small Livewire components here and there, rather than going all-in with Livewire. The entry point for these routes tends to be a show.blade.php file, which centralizes the layout for the page.
Another thing I found curious is that the Http/Livewire directory is pretty flat (see it here: Livewire Directory). It doesn’t use a livewire folder inside the views directory like some other setups might. This got me thinking about how this might affect organization and scaling as the project gets bigger.
My Take on It:
I actually like the idea of organizing things by feature—it keeps everything focused and easy to find. And having that single entry point like show.blade.php makes the layout more predictable. If this were my own project, whether personal or for a company, I’d probably do something similar. However, I might lean towards using Volt instead of class-based Blade components because I like how everything stays in one place with Volt—it just feels tidier to me.
I’m also thinking about the approach of starting with a controller. It’s a good starting point, but the tricky part is deciding when to shift from Blade over to Livewire. Jetstream seems to mix actions with inline logic in places like DeleteUserForm.php, which can be pretty flexible. But it does raise questions about maintainability and where to draw the line between keeping things simple and being overly granular.
I’d love to hear how others are handling similar setups or any thoughts on where Jetstream could do things differently. What would you change if it was your personal/enterprise project? submitted by /u/Eznix86
[link] [comments]
gpg check fails when installing wp-cli using ansible role debops.wpcli
Programing Coderfunda September 05, 2024 No comments
I have this in my meta/main.yml:
---
dependencies:
- role: debops.debops.wpcli
I have this in my ansible log:
TASK [debops.debops.wpcli : Install required APT packages] *********************
ok: [webserver]
Thursday 05 September 2024 06:45:21 +0000 (0:00:02.504) 0:01:21.198 ****
Thursday 05 September 2024 06:45:21 +0000 (0:00:02.504) 0:01:21.197 ****
TASK [debops.debops.wpcli : Create wp-cli source directory] ********************
changed: [webserver]
Thursday 05 September 2024 06:45:21 +0000 (0:00:00.852) 0:01:22.051 ****
Thursday 05 September 2024 06:45:21 +0000 (0:00:00.852) 0:01:22.050 ****
TASK [debops.debops.wpcli : Download wp-cli release files] *********************
skipping: [webserver] => (item={'url': '
https://github.com/wp-cli/wp-cli/releases/download/v2.2.0/wp-cli-2.2.0.phar.gpg', 'dest': '/usr/local/src/wpcli/wp-cli-2.2.0.phar.gpg', 'checksum': 'sha256:6ed3c78adea2801ce900f3dc8f09ce799958955cc842b5f8d17d8ffb74eca7a2', 'version': '2.2.0'})
skipping: [webserver] => (item={'url': '
https://raw.githubusercontent.com/wp-cli/wp-cli/v2.2.0/utils/wp-completion.bash', 'dest': '/usr/local/src/wpcli/wp-cli-2.2.0.completion.bash', 'checksum': 'sha256:443ca0610ccae8d2d6aceba0ec4aa7929b87ed6cf54f666afed18d663a18a395', 'version': '2.2.0'})
skipping: [webserver] => (item={'url': '
https://github.com/wp-cli/wp-cli/releases/download/v2.3.0/wp-cli-2.3.0.phar.gpg', 'dest': '/usr/local/src/wpcli/wp-cli-2.3.0.phar.gpg', 'checksum': 'sha256:24e16d96d22baec166ffb8807bf751cabd62b84e1716523f94d61b2a8d7e2255', 'version': '2.3.0'})
skipping: [webserver] => (item={'url': '
https://raw.githubusercontent.com/wp-cli/wp-cli/v2.3.0/utils/wp-completion.bash', 'dest': '/usr/local/src/wpcli/wp-cli-2.3.0.completion.bash', 'checksum': 'sha256:443ca0610ccae8d2d6aceba0ec4aa7929b87ed6cf54f666afed18d663a18a395', 'version': '2.3.0'})
skipping: [webserver] => (item={'url': '
https://github.com/wp-cli/wp-cli/releases/download/v2.4.0/wp-cli-2.4.0.phar.gpg', 'dest': '/usr/local/src/wpcli/wp-cli-2.4.0.phar.gpg', 'checksum': 'sha256:c009a0d9e84436eab671272ca0d0a75b5aefd1af17177c83c2b33ad945976def', 'version': '2.4.0'})
skipping: [webserver] => (item={'url': '
https://raw.githubusercontent.com/wp-cli/wp-cli/v2.4.0/utils/wp-completion.bash', 'dest': '/usr/local/src/wpcli/wp-cli-2.4.0.completion.bash', 'checksum': 'sha256:443ca0610ccae8d2d6aceba0ec4aa7929b87ed6cf54f666afed18d663a18a395', 'version': '2.4.0'})
changed: [webserver] => (item={'url': '
https://github.com/wp-cli/wp-cli/releases/download/v2.5.0/wp-cli-2.5.0.phar.gpg', 'dest': '/usr/local/src/wpcli/wp-cli-2.5.0.phar.gpg', 'checksum': 'sha256:a5faf98302ac3c96f0aad38e5d1a7142cfbd28fc2df03c687094b3fbf67a19a8', 'version': '2.5.0'})
changed: [webserver] => (item={'url': '
https://raw.githubusercontent.com/wp-cli/wp-cli/v2.5.0/utils/wp-completion.bash', 'dest': '/usr/local/src/wpcli/wp-cli-2.5.0.completion.bash', 'checksum': 'sha256:443ca0610ccae8d2d6aceba0ec4aa7929b87ed6cf54f666afed18d663a18a395', 'version': '2.5.0'})
Thursday 05 September 2024 06:45:24 +0000 (0:00:02.864) 0:01:24.916 ****
Thursday 05 September 2024 06:45:24 +0000 (0:00:02.864) 0:01:24.915 ****
TASK [debops.debops.wpcli : Verify and install wp-cli binary] ******************
fatal: [webserver]: FAILED! => changed=true
cmd: set -o nounset -o pipefail -o errexit && gpg --batch --decrypt --output /usr/local/src/wpcli/wp-cli-2.5.0.phar /usr/local/src/wpcli/wp-cli-2.5.0.phar.gpg && ( install --mode 755 --owner root --group root /usr/local/src/wpcli/wp-cli-2.5.0.phar /usr/local/bin/wp && install --mode 644 --owner root --group root /usr/local/src/wpcli/wp-cli-2.5.0.completion.bash /etc/bash_completion.d/wp-completion ) || ( rm -f /usr/local/src/wpcli/wp-cli-2.5.0.phar && exit 2 )
delta: '0:00:00.092231'
end: '2024-09-05 06:45:25.499750'
msg: non-zero return code
rc: 2
start: '2024-09-05 06:45:25.407519'
stderr: |-
gpg: directory '/root/.gnupg' created
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: Signature made Wed May 19 15:24:41 2021 UTC
gpg: using RSA key 63AF7AA15067C05616FDDD88A3A2E8F226F0BC06
gpg: issuer "releases@wp-cli.org"
gpg: Can't check signature: No public key
stderr_lines:
stdout: ''
stdout_lines:
For me this reads as:
* I am using the debops role wpcli in the correct way because it starts installing WP-CLI
* But the currect public key that is used to sign WP-CLI is not found
Is my assumption correct?
How do I fix this problem?
04 September, 2024
GitHub Desktop is not signing GPG key automatically
Programing Coderfunda September 04, 2024 No comments
I also tried setting the path of the gpg program in .gitconfig to
[gpg]
program = "C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe"
However, if I try to open the repo in Command Prompt, it actually works (it allows me to commit and enter the passphrase). I have correctly installed gpg4win and I'm on Windows 10. Can anyone help me here?
Chaperone Eloquent Models in Laravel 11.22
Programing Coderfunda September 04, 2024 No comments
The Laravel team released v11.22 this week, with the chaperone() Eloquent method for inverse relations, support for passing backed Enums to Queuable methods, the ability to pass backed Enums to route ->name() and ->domain() methods, and more.
Chaperone Eloquent Relations
Samuel Levy contributed the Eloquent inverse/chaperone model relation that Taylor demonstrated in his 2024 Larcon US keynote during the open-source part of the talk.
public function comments(): HasMany
{
return $this->hasMany(Comment::class)->chaperone('post');
}
The chaperone()/inverse() method avoids unexpected N+1 queries by linking back to the parent after the relationship query has run. The above relationship will link the appropriate Post model in the correct relation on Comment instances (with scopes intact).
See Pull Request #51582 for more details.
Support Backed Enum in the Queueable Trait
Seth Phat contributed support for BackedEnum in Queuable trait methods:
*
onQueue()
*
onConnection()
*
allOnQueue()
*
allOnConnection()
Here's an example from the pull request:
use App\Enums\QueueConnection;
use App\Enums\QueueName;
// Before
public function register()
{
$user = User::create([...]);
SendWelcomeEmailJob::dispatch($user)
->withConnection(QueueConnection::REDIS->value)
->onQueue(QueueName::HIGH->value);
}
// After
public function register()
{
$user = User::create([...]);
SendWelcomeEmailJob::dispatch($user)
->withConnection(QueueConnection::REDIS)
->onQueue(QueueName::HIGH);
}
Allow Enums to be Passed to Routes
@NickSdot contributed passing BackedEnum to Route domain() and name() methods:
// Before
Route::domain(InterfaceDomain::Marketing->value)
->name(Routes::Home->value)
->get('/contact', ContactController::class);
// After
Route::domain(InterfaceDomain::Marketing)
->name(Routes::Home)
->get('/'contact, ContactController::class);
Release notes
You can see the complete list of new features and updates below and the diff between 11.21.0 and 11.22.0 on GitHub. The following release notes are directly from the changelog:
v11.22.0
* [11.x] Fix FoundationServiceProvider docblock by @seriquynh in
https://github.com/laravel/framework/pull/52542
/>
* [11.x] Fix ReflectionParameter @param type on Util::getContextualAttributeFromDependency() by @samsonasik in
https://github.com/laravel/framework/pull/52541
/>
* [11.x] More specific parameter type in CastsInboundAttributes by @lorenzolosa in
https://github.com/laravel/framework/pull/52536
/>
* [11.x] Unify prefetch API by @timacdonald in
https://github.com/laravel/framework/pull/52550
/>
* [11.x] Add PDO subclass support for PHP 8.4 by @ju5t in
https://github.com/laravel/framework/pull/52538
/>
* [11.x] Handle circular references in model serialization by @samlev in
https://github.com/laravel/framework/pull/52461
/>
* [11.x] Eloquent inverse relations by @samlev in
https://github.com/laravel/framework/pull/51582
/>
* [11.x] Feature/whereany closures by @liamduckett in
https://github.com/laravel/framework/pull/52555
/>
* [11.x] Update remaining workflows to run on latest possible ubuntu version by @Jubeki in
https://github.com/laravel/framework/pull/52566
/>
* Correct comments to better represent the updated method functionality by @dropweb in
https://github.com/laravel/framework/pull/52564
/>
* [11.x] Support CSP nonce by @timacdonald in
https://github.com/laravel/framework/pull/52558
/>
* [11.x] Allow enums to be passed to routes by @NickSdot in
https://github.com/laravel/framework/pull/52561
/>
* [11.x] SORT_NATURAL on Collection no longer throws warning for nulls by @Chaplinski in
https://github.com/laravel/framework/pull/52557
/>
* [11.x] Allow prefetch to start on custom event by @timacdonald in
https://github.com/laravel/framework/pull/52574
/>
* [11.x] Fix regression in database assertions with custom model connections by @devfrey in
https://github.com/laravel/framework/pull/52581
/>
* [11] Update DetectsLostConnections.php by @webartisan10 in
https://github.com/laravel/framework/pull/52614
/>
* Fix docblock for Model::getEventDispatcher() by @inmula in
https://github.com/laravel/framework/pull/52602
/>
* [11.x] Restore Request::HEADER_X_FORWARDED_PREFIX in TrustProxies by @taka-oyama in
https://github.com/laravel/framework/pull/52598
/>
* [11.x] Accepts BackedEnum for onQueue, onConnection, allOnQueue, and allOnConnection methods in the Queueable trait by @sethsandaru in
https://github.com/laravel/framework/pull/52604
/>
* [11.x] Use the same parameter type for 'throwUnless' as used for 'throwIf' by @pataar in
https://github.com/laravel/framework/pull/52626
/>
* [11.x] Pass iterable keys to withProgressBar in InteractsWithIO by @robinmoisson in
https://github.com/laravel/framework/pull/52623
/>
* [11.x] Fix docblock for Filesystem::hash() by @sunaoka in
https://github.com/laravel/framework/pull/52630
/>
* Fix Apostrophe Handling in SeeInOrder.php and Enhance Test Coverage by @nomitoor in
https://github.com/laravel/framework/pull/52627
/>
* [11.x] SQLite Error: "General error: 1 no such table" after adding a foreign key when using a table prefix. by @incrize in
https://github.com/laravel/framework/pull/52578
/>
The post Chaperone Eloquent Models in Laravel 11.22 appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.