Skip to content

Conversation

@andy-stark-redis
Copy link
Contributor

@andy-stark-redis andy-stark-redis commented Nov 5, 2024

DOC-4520

New client page for PHP. Note that we probably can't add examples for testing and we won't be supporting the full range of tabbed samples for PHP just yet.

@andy-stark-redis andy-stark-redis requested review from a team and mortensi November 5, 2024 16:46
@andy-stark-redis andy-stark-redis self-assigned this Nov 5, 2024
@andy-stark-redis andy-stark-redis marked this pull request as ready for review November 5, 2024 16:47
Copy link
Collaborator

@dwdougherty dwdougherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a few tweaks.

@andy-stark-redis
Copy link
Contributor Author

@dwdougherty Feedback applied. Thanks for spotting those problems.

Copy link
Collaborator

@dwdougherty dwdougherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

use Predis\Client as PredisClient;

$r = new PredisClient([
'scheme' => 'tcp',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this are default values, can be omitted for simplicity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladvildanov I've removed them. There's another example in the page that illustrates them, so as you say, best to use the simplest example to start off.

Store and retrieve a simple string to test the connection:

```php
echo $r->set('foo', 'bar'), PHP_EOL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP_EOL constant is equal to "\r\n", should be concatenated with other string echo $r->set('foo', 'bar') . PHP_EOL;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladvildanov The doc page for echo says you can use either the comma (ie, two parameters) or the dot (ie, concatenation) for this. Is there any reason to prefer concatenation here (efficiency, standard practice, etc)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm thanks for pointing out. In this case it should be fine. This was based on my personal experience, I never meet the comma approach.


echo var_export($r->hgetall('user-session:123')), PHP_EOL;
/*
array (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array() call is an old way to create an array, used before 5.4 version. The best practice now is a new notation, just like in the other versions [ 'name' => 'John', 'surname' => 'Smith', 'company' => 'Redis', 'age' => '29',];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladvildanov This comment shows the output from the echo command. The var_export function does actually format the array string like this (I've just tried it). In most of the other examples, we have ">>>" at the start of output sample comments to make it clearer that were showing the results of the previous command. I'd forgotten to add them here but I've put them in now.

@andy-stark-redis andy-stark-redis merged commit 269e475 into main Nov 6, 2024
5 checks passed
@andy-stark-redis andy-stark-redis deleted the DOC-4520-php-client-page branch November 6, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants