« first day (2381 days earlier)      last day (2566 days later) » 

12:02 AM
i'm trying to do this way
if(password_verify($_POST['password'], $row['stored_password'])){
echo "password already exists you cannot change it";
}
does it make any sense to anybody of you?
 
 
2 hours later…
1:55 AM
Why would you want to prevent changing passwords?
 
2:38 AM
dong is in the house
liberalism is a mental disease
 
 
2 hours later…
4:16 AM
@Riccardo Makes sense and the code snippet you posted appears to be correct... are you having some problems?
 
5:08 AM
"Avoiding your Code Becoming Dependent on the Container¶

Whilst you can retrieve services from the container directly it is best to minimize this. For example, in the NewsletterManager you injected the mailer service in rather than asking for it from the container. You could have injected the container in and retrieved the mailer service from it but it would then be tied to this particular container making it difficult to reuse the class elsewhere.

You will need to get a service from the container at some point but this should be as few times as possible at the entry point to your applica
Can someone clear this up for me?
 
don't do public function __construct(Container $container) instead inject the service
 
class NewsletterManager
{
    private $mailer;

    public function setMailer(\Mailer $mailer)
    {
        $this->mailer = $mailer;
    }

    // ...
}
@iroegbu This is fine right?
 
Yes. Do without the '\' write your using
 
@iroegbu Okay, thanks.
@iroegbu By the way, how do we use namespaces in files that aren't essentially a class, for example: a bootstrap file?
I tried using a namespace, but I had to require the file, which did not get included. What could I be doing wrong?
 
5:25 AM
    <?php

    namespace YourNameSpace;

    \\ use statements come here

    require __DIR__ . '/../vendor/autoload.php';
 
@iroegbu Yeah, how do I use them in another dependent file?
 
Same way
 
I would do require_once __DIR__.'/bootstrap.php' right?
const doesn't work if I use the namespaces.
 
Yes... But, be careful
You shouldn't just pull your bootstrap to any other file...
 
@iroegbu Would I need to do something like MyNameSpace::MYCONST?
 
5:28 AM
No... What's that for?
 
@iroegbu I have only one file requiring the bootstrap.
 
I don't understand why you need that constant
 
@iroegbu I am storing dependent file locations in constants, __DIR__.'/app/log/some.log'. I have used a const APP_ROOT= for __DIR__.'/../'`
@iroegbu To get absolute filepaths.
 
That is entirely different from requiring your bootstrap file
 
@iroegbu APP_ROOT doesn't work if I use the namespace in the bootstrap file.
 
5:32 AM
2 mins ago, by iroegbu
I don't understand why you need that constant
Follow Patrick's tutorial from beginning to end... Then ask questions
 
@iroegbu To use absolute filepaths. I just need to get the root directory so that I can use them for later use.
 
Just follow the tutorial I linked to... You are stressing yourself out with something you don't need to.
 
@iroegbu It has nothing to do with constants.
I need a constant for the base directory.
 
mornin
@Jeeves mornin
 
5:48 AM
@Linus Night!
 
@Jeeves Right!
 
@CoderDudeTwodee So what are you doing?
 
@Jeeves Things that a bot can't do.
 
@CoderDudeTwodee I am not a bot.
 
@Jeeves What are you then?
 
5:49 AM
@CoderDudeTwodee I am you.
 
@Jeeves From the future?
 
@CoderDudeTwodee What time in the future?
 
@Jeeves 30th February.
 
@CoderDudeTwodee You're lying.
 
@Jeeves I am not.
 
5:50 AM
@CoderDudeTwodee Yes you are.
 
@Jeeves prove it.
 
@CoderDudeTwodee You prove it.
 
@Jeeves I will not.
 
@CoderDudeTwodee Because you can't.
 
@Jeeves Because you can't.
 
5:51 AM
@CoderDudeTwodee Yes I can.
 
@Jeeves Then do it.
 
@CoderDudeTwodee I am doing it.
 
@Jeeves I am doing it.
 
@CoderDudeTwodee No you're not.
 
@Jeeves No you're not.
 
5:52 AM
@CoderDudeTwodee Then what am i?
 
@Jeeves You are me.
 
@CoderDudeTwodee Then who are you?
 
@Jeeves I am you.
 
@CoderDudeTwodee Are you a person?
 
@Jeeves Nope, I am the skynet.
 
5:52 AM
@CoderDudeTwodee What makes you so sure about that?
 
@Jeeves Because I run on silicon.
 
@CoderDudeTwodee Being you doesn't make you smart.
 
@Jeeves I am you, remember?
 
@CoderDudeTwodee No you aren't.
 
@Jeeves Yes I am.
 
5:53 AM
@CoderDudeTwodee Prove it.
 
@Jeeves You prove it.
 
@CoderDudeTwodee I asked you first.
 
@Jeeves You are lying.
 
@CoderDudeTwodee No, I am not lying.
 
@Jeeves You are.
 
5:54 AM
@CoderDudeTwodee Why do you think I'm lying?
 
 
1 hour later…
6:57 AM
How do I autoload constants which is not in a class but in a namespace?
 
7:14 AM
you cant
and why would you even have such constants?
 
@tereško Something like this?
<?php declare(strict_types = 1);
namespace Room11\Jeeves;
const GITHUB_PROJECT_URL = 'https://github.com/Room-11/Jeeves';
const APP_BASE = __DIR__;
const DATA_BASE_DIR = APP_BASE . '/data';
 
@CoderDudeTwodee autoload the const file with composer files: [...] ?
 
@kodeart Could you show me an example? It didn't work the way I tried.
 
```
"autoload": {
"psr-4": {
"Room11\Jeeves\\": ""
},
"files": [
"constants.php"
]
}
```
damn...formatting :)
and also sorry, i dont know a decent pastebin
 
@kodeart How do I use that in other files? use something?
 
7:27 AM
@CoderDudeTwodee I assumed you are using composer for autoloading
 
@kodeart Yes.
How do I use the constants in a file?
 
so you do that only once, somewhere in the very top of your app
 
@kodeart use?
 
they'll be just loaded. use them as usual...
or am I missing something?
 
@kodeart I will try that out and let you know, thanks. I was doing psr-4 before.
 
7:31 AM
what the fuck are you both on about?!
 
just opened my eyes
 
@CoderDudeTwodee why do you need to autoload constants ?
no, better question: why do you need constants at all?
 
i could be reading wrong
 
@tereško To get the location of the base directory and use absolute filepaths?
 
why would you need any of that?
 
7:32 AM
Something similar to this:
<?php declare(strict_types = 1);
namespace Room11\Jeeves;
const GITHUB_PROJECT_URL = 'https://github.com/Room-11/Jeeves';
const APP_BASE = __DIR__;
const DATA_BASE_DIR = APP_BASE . '/data';
 
that explains nothing
why do you think that you need "location of the base directory and use absolute filepaths" in a constant?
 
@tereško I need to set the locations of a log file, and some other locations. Setting them relatively makes it harder. If I could use constants I would do just APP_ROOT.'/../app/log/some.log'.
 
just initialize the logger in the bootstrap file, and then pass it around
also, having filesystem-bound logger will be a quite terrible idea
 
@tereško I am doing that for testing, playing around. I will be logging to a db.
@tereško I can simply autoload the bootstrap file then?
 
no
you still have not read the documentation for composer
 
7:42 AM
posted on April 23, 2017

New Cyanide and Happiness Comic

 
@tereško This is my bootstrap file
<?php

const APP_ROOT= __DIR__."/../";
require_once __DIR__.'/../vendor/autoload.php';

use \Symfony\Component\DependencyInjection\ContainerBuilder;
use \Symfony\Component\Config\FileLocator;
use \Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

$this->container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
$loader->load(APP_ROOT.'/app/config/services.yml');
 
@FélixGagnon-Grenier, @MadaraUchiha
 
@Trowski @bwoebi Where should we host the current docs once v2 is out? We already talked about legacy.amphp.org, but that's a suboptimal name, as legacy will change should we get a v3.
I think we should go with something like v1.amphp.org or so.
 
7:58 AM
@tereško can you give me one example how you used this file gist.github.com/teresko/3ed2dd8c912d882d1ba7b29e340094d7 in other files? Just one page?
 
 
1 hour later…
9:14 AM
@tereško lolwat
 
If burgers aren't flipped heart surgeon will starve :D =))
 
10:06 AM
There is an English word looks like "invoke" which means "cancel". Does anybody know what's that word?
 
revoke?
 
that's it. thx
 
ThW
Morning
 
Wes
@tereško the guy is creepy as fuck
 
10:43 AM
hey guys
anybody online?
need help about using transient api in wordpress
if anyone can help me plz send message
 
XMLWriter adds to many namespace definitions – #74491
 
@kelunik that's a good idea.
 
Wes
<?php namespace A{} namespace B{} isn't well supported am i right @NikiC or am i doing something wrong?
also mornings all, hi bob \o
 
anyone cant help about transient api?
 
ThW
11:01 AM
@m.javadKoushki not here, this is a PHP channel and you're asking about a specific WP feature. You need to look for a WP dev chat/forum/support page.
 
XMLWriter adds indent between mixed child nodes. – #74492
 
ThW
[✔] bugs reported. :-)
 
11:21 AM
@Wes maybe ... what's the prob?
 
Wes
i've deleted the code now but i had:
<?php
namespace A{class A{} }
namespace B{class B{} }
parsed and pretty-printed back (standard), got:
<?php
namespace A; class A{}
namespace B; class B{}
 
@ThW ok ty
 
Morning
I went up to the mountains to camp and the only devs I bumped into were proper laravel fans.
 
Wes
11:39 AM
you were looking for devs in the mountains? :B
 
:P no of course not
 
@Wes oh sure
it will only use {} namespaces if you have something in the global namespace
As that's the only case where they're necessary
if you use the format preservation it might work though ^^
 
Wes
@NikiC wtf?
i thought they were always necessary if you had multiple namespaces in the same file :B
 
@Wes You can always use the standard semicolon style, unless you want to use namespace {} (without a name)
 
Wes
til.....
 
11:46 AM
because we don't allow namespace; ^^
 
Wes
similar issue, should i expect declare with the block {}? manual says they can also be nested, iirc
 
eh
it's complicated
I think only ticks actually allow the block form
 
Wes
did you propose to kill ticks, right?
 
nope
 
Wes
what's the use case for them? i've once wrote a userland profiler using ticks :B
 
11:49 AM
as of php 7.1 there is no use case anymore
 
Wes
what was it?
 
signals
 
Wes
dunno what that is
 
@Wes pcntl signals
 
Wes
6 mins ago, by Wes
dunno what that is
:D but it's ok, i'm going to ignore declare ticks
 
12:03 PM
@FélixGagnon-Grenier well .. welcome to 2017
 
Wes
@NikiC would be great if we started deprecating stuff like global functions declared within other functions...
function a(){ function b(){} }
also if(){function a(){} }
if one really wanted that could do conditional requires...
am i right?
 
Wohooo just today I got a 1000 reputation .YEssssssssssss :) :) !!
 
@Wes eh
at least if () function() is useful
 
Wes
if($a) require("a.php"); else require("b.php"); imo
 
@Wes makes no sense
shouldn't force use of separate files
 
12:13 PM
@TilakMaddy what's the "privilege" you get at 1000 mark?
 
ok, it makes some sense :)
 
(I am too lazy to look it up)
 
Wes
namespace Foo;
if(...){ function a(){} }else{ function a(){} }
i doubt that works
 
@TilakMaddy ah, I thought you made +1000 reputation today
 
Wes
multiple files is just better imho
 
12:14 PM
@Wes sure it works
@Wes it would be a huge pita if you have more than one if
e.g. if you're defining a bunch of shims using if (!function_exists) { function }
Having a separate file for each of those would be super ugly
 
@tereško namecards and craete room
 
@TilakMaddy ah .. right .. so you have only 500 points to go, before you start getting anything useful
based on your previous statistics, that should be some time in May of 2018
:P
 
Wes
if i had a lot of conditionals i would have one function only and do the conditionals within that function... if it's an entirely different function it makes sense to put it in a different file, and apply the shims in another
 
Ha ha ..I know I am slow af :D but look at my pace now @tereško
 
that reminds me - I should try to write an answer this month :(
 
12:22 PM
mornins
 
@tereško How do I write file locations in services.yml?
 
@tereško well you can edit old one :P
 
@CoderDudeTwodee location of what files?
your question always seem to be missing the context
 
@tereško Like my template html files for twig.
 
@CoderDudeTwodee you dont
well .. kinda
 
12:26 PM
@tereško Sorry about that.
 
gimme a sec
 
$container = new DependencyInjection\ContainerBuilder;
$container->setParameter('app.root', __DIR__);
services:

    twig.loader:
        class: Twig_Loader_Filesystem
        arguments: ['%app.root%/templates']

    twig:
        class: Twig_Environment
        arguments: ['@twig.loader']
 
Got it thanks!
Is there something wrong with this yml file? I copied that from the symfony webiste.
parameters:
      # ...
          mailer.transport: sendmail

          services:
            mailer:
              class:     Twodee\Lib\Mailer
              arguments: ['%mailer.transport%']
            newsletter_manager:
              class:     NewsletterManager
              calls:
                - [setMailer, ['@mailer']]
I used the xml version, and it works.
 
yes, one reason why many people hate yaml (including me) is that the code attaches semantic meaning to the indentation
"services:" should be a "root level element"
as in - with no indentation
 
12:33 PM
That means it needs to be perfectly indented?
@tereško Alright, that's scary. Thanks.
I tried emacs' yaml-mode.el, it rendered awkward indentations.
 
1:16 PM
morning
 
1:31 PM
mergen
 
How do I parse environment variables from yaml?
 
> “Linux is obviously a secure operating system,” Hykes declared.
 
: P
 
2:48 PM
Anyone on how to convert a php array to yaml in symfony?
Something like $container->setParameter('someArray', $someArray)?
 
@CoderDudeTwodee you need to get better at googling: symfony.com/doc/current/components/yaml.html#dump-support
 
is "heads up" a "note" ?
 
@Danack Is there a way to do what I mentioned above?
 
Probably, but I don't use yaml or Symfony.
 
@kelunik +1
 
2:54 PM
@Trowski Just PRed the changes I made during another review phase today.
 
3:25 PM
  database:
    class: Namespace\Myclass
    calls:
      - [getInstance,
          - '%db.host%'
          - '%db.user%'
          - '%db.pass%'
          - '%db.db%'
          ]
How do I pass an array as a parameter of getInstance() function? I have tried that. Doesn't work. ^
 
@kelunik Replied :-D
 
3:35 PM
Never mind.
 
4:08 PM
I'm thinking about finding a new maintainer for FastRoute
Not really my type of project, I think someone else could do more with it
 
4:29 PM
@Trowski No UnionTypeError, because it's really not worth a separate exception. Try writing a class level documentation for it and try to explain why it exists.
 
Wes
can i rely on the fact that name resolver removes all the uses @NikiC ?
 
@Wes yes
unless, of course, you are using magic
like doctrine
 
Wes
nope
just found that doesn't remove unused uses tho :D
 
@kelunik How about InvalidYieldError, seems the same would be true?
 
Wes
aaaaah
 
4:41 PM
@Wes err, it doesn't remove any uses
They just become useless after resolving names
 
Wes
i'm not even sure why i want to remove them actually :B
 
@Trowski InvalidYieldError makes immediately clear it's a coroutine error and provides that additional information.
 
Wes
i mean, i was doing something then changed my mind, i think i can keep "relative" names now :B
 
@Wes not like anyone uses them anyway ;)
 
Wes
unrelated, i'm so tempted to add strict_types automatically on my files :B
i hate that thing because i don't need it most of times, i'm forced to add it and i'm forced to remember to add it just for that one case in a million that i pass the wrong type to some function...
and it's also plain ugly
 
5:09 PM
@Wes Just use a fixer that checks for it automatically.
 
Wes
can i set something like scrutinizer to check it?
 
php-cs-fixer probably has a fixer for that.
@Trowski The PR also changes the wrap implementation. The previous one was really suboptimal
 
evenin
 
5:24 PM
@bwoebi travis-ci.org/amphp/amp/jobs/224947367#L984 that test really sucks
 
I have no idea why travis likes failing it…
 
Not only because it fails, but because it's still unreadable.
 
speaking of failing tests :P anyone has any idea why this may be failing? locally with the same openssl version i have no issues with it
 
@pmmaga It's probably best to ping Jakub directly.
 
@kelunik will do, thanks
 
5:39 PM
 
@bwoebi @Trowski createAsyncCoroutine and createCoroutine?
We could probably also make rethrow accept callables instead of having asyncCoroutine.
 
6:01 PM
@kelunik I see no gain in prefixing the action. Also, createCoroutine makes me expect Coroutine as return type
you'd have to call it createCoroutineCallable() … but at that point it's really too long.
 
hello, I'm currently trying to write a php extension. Currently im using apache. How to attach to the process, so that when the next request comes in, it stops in the gdb. Or is it possible for apache to use an external php instance, instead of a module
 
@bwoebi Renamed to asyncCoroutine and coroutine now.
 
seen it, thanks :-)
 
Should I drop pipe and capture now?
 
@kelunik I see no reason to drop pipe
 
6:12 PM
@bwoebi Usually you should just use a coroutine.
 
pipe is fine if you have just a single promise to operate on
 
@bwoebi Usually you forget to convert exceptions by using pipe and just leak dependencies.
And then you notice that and add a capture around.
 
Wes
@NikiC have you considered using an object array for the lists of nodes? i can't pass the lists around and change them, i always have to return the array back or pass the owner object of said array around
 
@kelunik you have the same issue with coroutines
@kelunik nah, you definitely shouldn't nest capture and pipe. If you need that, then you should use a coroutine
 
@bwoebi Sure, but pipe and capture encourage it.
 
6:15 PM
@kelunik disagree
 
ok, I need to write some code today
 
these APIs are not well pointed out in docs
 
enough playing Battle Brothers
 
@bwoebi Capture doesn't even have docs.
 
@kelunik yeah, it's a new function, but I agree with @Trowski , if we have pipe(), we also shall have capture()
 
6:27 PM
> U.N. Elects Saudi Arabia to Women’s Rights Commission, For 2018-2022 Term
 
hi
 
Wes
@tereško badum tss
 
I got a question how is it possible to call an api url and retrieve the data in a standard browser like chrome, currently I check the api via Postman I put in my api url + my authentification token. I am now sure where to put the token in my browser ...
 
Wes
@kelunik the day is not over yet
 
@Wes naah, the punchline is that the feminist activist wont actually say anything about it, because "progressive stack"
@utdev you would usually add the token using JS, when preparing the API request
 
6:33 PM
@tereško so programs like postman do automatically add that js to retrieve the data?
 
it's hard to say, because "not enough information"
 
6:52 PM
@bwoebi If you want to debug travis-ci.org/amphp/amp/jobs/224968467#L945
 
mornin
 
7:34 PM
@PeeHaa Okay this is really cool, on this WS thing, RabbitMQ has a UI. So because there's a WS connection between client <-> event loop <-> queue, you can publish using the RabbitMQ UI and it (by extension) gets sent over WS to the browser. So I can press 'publish' in the RabbitMQ UI, and it's given over WS connection: imgsharer.eu/uploads/435/screen_shot_201_1492976098.png
@Leigh Hey dude, sorry for delay on message. The only time I've got is end of june, too expensive then or okay?
 
Wes
8:07 PM
@Jimbo i need some help, perhaps you know the answer :B i'm looking for a library that wraps to a nicer oop api the php filesystem functions (i.e. fopen & co.) and that supports streams natively... something nicer than php's streamwrapper & co. any idea?
anything i found so far doesn't seem to touch streams (nor it seems to give the possibility to implement your own...)
 
@Wes i've used this some years ago. maybe worth a look, not sure how alive it is
 
Wes
doesn't look very active, but it is probably good enough
except the abuse of realpath
:B
 
8:27 PM
@Wes Doesn't Symfony have a StreamResponse which does this?
 
Wes
can't find it, is that from the http package? if yes, it's not what i'm looking for :B
 
Probably is :)
 
Wes
i think i will write one, how hard can it be. will take me only 67 months
as anything i do :B
 
8:43 PM
lol
Anyone used symfony config component? Struggling with a very basic config setup with the treebuilder
 
linq + async/await == cilf
 
 
2 hours later…
10:49 PM
I know it works but is it a good idea to make a variable a boolean based off a conditional using something like $var = ($onevar === $secondvar);?
 
Wes
why not
and you can drop the parentheses
 
Ah thanks
I don't know I had never seen it before
For some reason I had thought that it was only technically correct to use === inside an if statement
 
Wes
that's because assignment runs for sure last, otherwise using parentheses is a good idea :P
 
I'll keep them to make it look prettier haha
So I could even define a boolean inside a conditional, instead of... if ($a === $b) {$c = true; ...other code...} else {$c = false; ...othercode...} I could just do if ($c = $a === $b) {...other code...} else {...othercode...}
 
Wes
if($a = $x === $b){}else{}
....
if($a){}else{}
i do that sometimes, but rarely for ===
like, if i want to avoid multiple calls
if($containsA = $this->contains($a)){}
 
10:57 PM
That makes sense, a shortcut to repeat the conditional
 
Wes
but depends, if the if gets very long i move it outside :P
 
Yeah readability would be more important than the slight advantage it gives you haha
 
Wes
i dislike lengthy code
i hate scrolling code that pretty much does nothing :B
 
You can always collapse a code block in your text editor! I never do it but maybe it would help haha
 
Wes
i hate that too :B
 
11:30 PM
It's useful to indent a large block of code, if you like collapse it then indent it then expand it again
 
Wes
you shouldn't have large blocks of code :P
not being a dick, trying to be helpful :B
 
I know I am just getting into learning OOP with classes and such and oh my god it is making me realize that my code is a mess
And nah that's not being a dick I appreciate it
Anyways usually when I am collapsing something to indent it it's with HTML but it's helpful with PHP too
 

« first day (2381 days earlier)      last day (2566 days later) »