PHP

Support group for those afflicted with PHP. Don't ask to ask, ...
Dec 1, 2022 18:34
$node->textContent = "<span> .... </span>"; of course works fine, but the result is a raw text, not HTML.
Dec 1, 2022 18:33
It returns: Wrong Document Error
Dec 1, 2022 18:33
It provides the appendChild method, but to make it simple, it doesn't work!

$xml = new DOMDocument();
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->loadXml("<span class='$class'>$line</span>");
$node->appendChild($xml->documentElement);
Dec 1, 2022 18:31
It's an object of this class
https://www.php.net/manual/en/class.domnode.php
Dec 1, 2022 18:28
I have a DOMNode. How can I append some HTML structures to it from a variable like "<span class='$class'>$line</span>"; ?
Apr 3, 2022 07:04
And by the way, if the question was good enough, vote it up; I've asked some unpopular questions, and this might be my last one
Apr 3, 2022 07:03
I'll be appreciated if someone could help me; I haven't been able to solve this problem for a few days ):

https://stackoverflow.com/questions/71723675/laravel-unlike-the-public-channels-private-channels-dont-work
Mar 29, 2022 17:35
I solved it; Imagick software, itself, wasn't installed for some reason!!
I have this command in my Dockerfile

apk add imagemagick

but hadn't ran, for a reason which I don't know I:
Mar 29, 2022 17:23
@Derick Yes; sorry; I forgot; I really have no idea what's going wrong ):
Mar 29, 2022 17:22
@Derick This file is in a volume; if the container didn't have the permission, I must not have been able to read it by some other commands like file_get_contents
Mar 29, 2022 17:17
Hello guys!
I've installed imagick in my docker container and php 8.1
Everything looks fine with PHP intervention, but when I want to load an image in this path:

"/usr/share/nginx/html/storage/app/uploads/2000/03/19/default_3/default_3.jpg"

which when I run file_exists returns true, it returns an error like:

Unable to read image from path (/usr/share/nginx/html/storage/app/uploads/2000/03/19/default_3/default_3.jpg).

Why?
Mar 29, 2022 05:32
@Derick Thanks; you were right; I hadn't installed some packages, and of course, I couldn't because I didn't have some other libraries :D Finally almost solved it.
Mar 28, 2022 17:15
What could be wrnog? ):
Mar 28, 2022 17:15
FROM php:fpm-alpine

RUN apk update && apk add build-base && apk add autoconf

RUN pecl install imagick && \
docker-php-ext-enable imagick
Mar 28, 2022 17:03
ERROR: `/tmp/pear/temp/imagick/configure --with-php-config=/usr/local/bin/php-config --with-imagick' failed
The command '/bin/sh -c pecl install imagick && docker-php-ext-enable imagick' returned a non-zero code: 1
Mar 28, 2022 17:01
Exactly, right now, I'm trying it using PECL
I think we don't have such a command, I mean: docker-pecl-ext-install
Mar 28, 2022 16:52
Can somebody help me to install `imagick` in docker? Here is my docker file:

FROM php:8.1-fpm-alpine

RUN apk update && apk add build-base && apk add autoconf

RUN docker-php-ext-install imagick && \
docker-php-ext-enable imagick

But doesn't work and returns:

error: /usr/src/php/ext/imagick does not exist
Mar 28, 2022 06:25
It's solved; thanks.
Mar 28, 2022 06:08
It seems the containers are completely seperated; when I run docker exec nginx php -v

it returns that it couldn't find the binary file
Mar 28, 2022 06:01
Funny! It exists when I run:

docker exec nginx ls /var/www
Mar 28, 2022 05:56
@Trowski YES
Mar 28, 2022 02:18
Hello guys; when I set my volumes in my docker-compose.yml file, the destination folder always is empty; why?

volumes:
- /var/www/html:/var/www/html:rw

When I run docker-compose exec php ls /var/www/html -l it returns 0 items.

I can't solve this problem; it's wasted most of my time ):
Mar 27, 2022 20:19
Some images in the hub were blocked for my IP address.
Mar 27, 2022 20:18
I installed a VPN, and everything seems ok now lol @IluTov , @Danack
Mar 27, 2022 18:55
This is all I get:

docker-compose up

WARNING: The vhT81Mjj39 variable is not set. Defaulting to a blank string.
Building php
Step 1/4 : FROM php:fpm-alpine
---> 2331e1d9fbdf
Step 2/4 : RUN apk update && apk add build-base && apk add autoconf
---> Running in 0026ac0ce082
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
v3.15.2-8-gcb4dbad273 [https://dl-cdn.alpinelinux.org/alpine/v3.15/main]
Mar 27, 2022 18:51
I thought when you run: "docker up" it will first try to make an image, and then run the container.
Good to know.
Mar 27, 2022 18:43
@IluTov If I could make an image, the other time that I try to make a new image, will the docker download and pull docker hub images again? or all the pulles will be cached?
Mar 27, 2022 18:24
I've tried to use Docker multiple times for my Laravel project; it always somehow disappointed me ):
Mar 27, 2022 18:22
If I could get some kind of error, I surely would google about it, but that's exactly the problem

It just gets stuck, without returning any error messages or even any other messages; sometimes I waited for hours, but nothing happened /:
Mar 27, 2022 18:19
Is anyone here familiar with Docker?

I've been trying to make an image file from my docker-compose.yml file; during the installation, it always get stucked at

`(1/19) Installing libstdc++ (10.3.1_git20211027-r0)`
or at the second stage which is:

(2/19) Installing binutils (2.37-r3)

I've tried to install it thoughts of times; sometimes it passed some more stages, but 99% of the times, it just get stucked in there
Dec 27, 2021 20:59
Hello guys

#Q Does anyone know how can I delete records which have foreign keys that piont to deleted or non-existent records(primary keys)?

I didn't set constraints for my relationships in the past; so, there are some mistakes in my database table records.
Jun 3, 2021 01:30
It seems your webserver doesn't use a PHP cgi.
Jun 3, 2021 01:23
Hi. How can I get the equation of a perceptron?

Is this correct?

b = bias
m = average of the weights
Apr 26, 2021 05:56
It's really important for me. I've been trying to solve the problem for some hours, but I couldn't understand the problem at all ):
Apr 26, 2021 05:55
#Q The $dispatchesEvents property doesn't work for me!

+ In my model I've overwritten the $dispatchesEvents.
+ I assign an event to update key of $dispatchesEvents.
+ In my event I try to log a message, but it doesn't get logged.

What's the reason?

protected $dispatchesEvents = [
'updated' => PostUpdated::class,
'saved' => PostUpdated::class,
];

Inside the constructor of PostUpdated

Log::warning("Post Updating Works Fine!!!");

#Laravel
Mar 27, 2021 13:50
Dependency Injection: Meant to use as a helper library in a dependency injection mechanism to call your functions / methods with the needed parameters

https://github.com/bylexus/php-injector
Mar 27, 2021 13:46
Right.
I think they were right also. It's dependency injection, and they call the libraries injectors!
Mar 27, 2021 13:40
Hmmm... It seems right. I don't know... You may be right! 🤔 Let me read it a little bit...
Mar 27, 2021 13:36
No no... It's not DI...
It has a nice name, and so many libraries, but I can't remember the name!
Mar 27, 2021 13:33
Hello Guys!

Does anyone know what was the name of the technique in which constructors with type hittings were being filled automatically?

Imagine:

class Do {
__construct(Job $job){$job->run()}
}

and the job is like this: Job(Property $property);

There were some techniques or libraries that automatically were doing llike the following:

$property = new Property();
$job = new Job($propery);
$do = new Do($job);
 

C#

General discussions about the c# language, Squirrels | gist.gi...
Mar 28, 2022 02:22
Isn't anyone here familiar with docker volumes?
Mar 28, 2022 02:20
Hello guys; when I set my volumes in my docker-compose.yml file, the destination folder always is empty; why?

volumes:
- /var/www/html:/var/www/html:rw

When I run docker-compose exec php ls /var/www/html -l it returns 0 items.

I can't solve this problem; it's wasted most of my time ):
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Mar 28, 2022 02:19
Hello guys; when I set my volumes in my docker-compose.yml file, the destination folder always is empty; why?

volumes:
- /var/www/html:/var/www/html:rw

When I run docker-compose exec php ls /var/www/html -l it returns 0 items.

I can't solve this problem; it's wasted most of my time ):
Jun 3, 2021 01:20
Hi. How can I get the equation of a perceptron?

Is this correct?

b = bias
m = average of the weights
 

JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
Mar 8, 2021 19:22
I think I have to iterate through all the child nodes of the body, and then get the text with a line break.

Something like:

let text = '';
for node in nodes:
text += node.textContent + '\n';

It works in my case, but I was hoping to find a better way.
Mar 8, 2021 19:19
Another question, are there any ways to get the whole text of the body tag with line breaks?

document.body.textContent

doens't give me the line breaks
Mar 8, 2021 18:59
Thank you guys. It's solved 🌺!
Mar 8, 2021 18:57
Let me try
Mar 8, 2021 18:52
It's been a half-hour that I'm looking for the answer, please, if you know the answer help me.
Mar 8, 2021 18:39
By the way, Hi!