« first day (2658 days earlier)      last day (2308 days later) » 

3:03 PM
function calculateDeliveryDate(int $timestamp = time()) { } why can't I do this? :(
 
@Naruto because time() is not a constant
and, seriously, how the hell would you unit-test it?
 
@tereško I wouldn't :)
 
the value from time() call should always be passed in the class from outside, otherwise it becomes very hard to test it
 
or use a clock as a dependency
 
@DaveRandom Both sites are the same
 
3:07 PM
@Naruto default parameters can't be something that needs to be executed.
 
It's 1 wbsite.
with 2 domains
 
@Naruto which is why were trying to make that architectural mistake
 
1 of them should be redirected by the main domain to a subfolder.
 
@Duikboot create another virtual host for the other domain, with it's document root pointed at the correct path
no rewrites or redirects needed
 
@StefanoTorresi there is no Clock in core PHP
 
3:09 PM
@Danack that makes sence yeah, it would have been nice, but it's not that it's that much work passing a timestamp in a function ^^
 
I said a clock, not THE clock.
 
function calculateDeliveryDate(int $timestamp = null) {
  $timestamp = $timestamp ?? time();
}
but I am inclined to agree with @tereško
just make it a required arg
 
eh
function calculateDeliveryDate(): int { ... }
sounds better to me
 
@Leigh how will you unit-test it?
 
Your $timestamp as a variable is meaningless. Timestamp of what?
 
3:11 PM
@tereško with a clock :D
 
@StefanoTorresi please, stop. You are embarrassing yourself.
 
@tereško I'd probably have function calculateDeliveryDate(DeliveryOptions $options, int $orderDate): int { ... }
But this is just a place to spam, not think
Actually I'd probably use DateTimes instead of ints
 
^ well DateTimeImmutable :P
 
@tereško wow, so snarky
 
Another one goes to ignore-list. Have a nice life.
 
3:15 PM
DatetimeInterface
it's not like you're in a multithreaded runtime
 
@FlorianMargaine touché
but it is not about multithreading
it's about some junior deciding to use that input in some other calculation ... defensive programming
 
is there some load testing tool that would allow me to put load on an fpm directly, e.g. without a webserver inbetween?
 
@Gordon so... a load testing tool that knows how to talk fastcgi and not http?
 
I've been the solo developer on a project for a year now, and I can honestly say, I'm not trying very hard to do things correctly anymore :|
 
@FlorianMargaine one that uses cgi-fcgi instead of an http client
 
3:18 PM
Also it's Laravel-based and YOLO, so fuckit
 
make a bush bash script that dumps shit from /dev/urandom in it?
 
I'm not sure if "bush script" is a typo or not
 
I am actively trying to work
btw, if you guys want to pick at something, you can try looking for flaws in this example: github.com/teresko/blank
I am trying to make a simple example for "how to make something MVC-like for people who chose the from profession"
 
You don't like strict types?
 
I don't like setters
and no return type declarations?
 
3:28 PM
@tereško Model around concepts. So "Entity" etc is useless, the first thing I should see should be "Account", with everything related to an account below that
 
Agree, I'd change that to __construct(int $accountId, DateTimeImmutable createdOn) and drop setters
 
the double blank lines are also throwing me off
 
also tell him the id shouldn't be mutable
 
DateTimeInterface
 
So... uh... Derick's response to the "Collection Inspection" thread...
 
3:31 PM
evenings room
 
@LeviMorrison I've wanted to do that for arrays…
 
@tereško public function fetch(Entity\Account $account)
this is weird imo. it should return that instead
 
> 2. isn't really complicated.

Would you allow collection<SomeInterface>, and would array_* work on them
 
fetch by id or whatever and return the constructed obj
 
@Patrick data mapper is not a factory
 
3:36 PM
pcntl_wexitstatus returns incorrect on Big_Endian platform (s390x) – #75873
 
@Leigh same reason. Data mapper is not a factory
 
@Leigh What about collection<collection<X>> and other recursive stuff
Collections of collections, yay
 
@tereško where did you get that from?
 
Generics types by themselves without any integration into the standard library, including standard interfaces, are really not that complicated. They are, however, a lot of work.
 
the original pattern (by fowler) doesn't even support fetch
 
Acute design patternicitis
 
> Its responsibility is to transfer data between the two and also to isolate them from each other.
 
To integrate with standard libraries and standard interfaces requires more features such as parameter type contravariance and return type covariance, and new types such as mixed and any (any is technically optional, but strongly preferred).
 
Everything mutable sounds like a nightmare to me
 
@Wes discovery omg wat
 
3:41 PM
@Patrick because you are part of the DDD sect
 
@tereško s/DDD/OOP
 
@Patrick Literally haven't found a use for immutability yet
 
@Patrick no, DDD
 
We don't 'accidentally call a method which overwrites a variable when we didn't want it to'
 
@Jimbo datetime->modify()?
I've encountered multiple bugs because of that over the years (introduced by different people)
 
3:44 PM
If I modify a date time, I modify a date time because I want to...
I don't have multiple threads accessing it at once
I have no idea why creating a new object would make any difference
 
same instance used in multiple places. suddenly someone modifies it to show +1 week or whatever -> bug introduced
 
@Jimbo Is "we" immutable?
 
seen it happen more than once
 
It's about developing succinct foolproof APIs, there is no setter because you're not supposed to be able to modify it
 
@Patrick hmm? IIRC the examples of PoEAA have plenty of find* methods
 
3:47 PM
@StefanoTorresi don't have a copy. was referring to the article
 
the article is just page 1 of the chapter
 
@StefanoTorresi does he also do it by passing in an object and then using setters?
 
he proposes both patterns
hmm, 1 mom
 
^ even fowler likes DDD
 
@Patrick he also suffixes everything with "model" and uses Rails - people have flaws
 
3:50 PM
Im hoping someone could help me out with this
without a rash of shit
I just installed the latest version of XAMPP with php 7.something and the whole world crashed
 
@tereško I agree. If he advocates setters, that would also be a negative from my POV
 
Now it doesnt execute PHP and just displays it on screen
so I found this
Under the heading: Modify the .conf file
but not sure what to do
 
@Patrick well no, it doesn't pass the object, ever, at most it instantiate an empty one and invoke the setters.
but it advises for using what he calls a "rich constructor"
 
that makes sense to me
 
I can figure out how open the console part. (I think)
 
3:53 PM
yep
 
but dont know what to do with
To do this, open a terminal window and issue the command:

sudo nano /etc/apache2/apache2.conf
With apache2.conf open, all you have to do is add the following to the bottom of the file:

<FilesMatch \.php$>
​SetHandler application/x-httpd-php
​</FilesMatch>
 
what's up with english stealing all the poetic french words?
 
sudo nano /etc/apache2/apache2.conf WTF?
the Fuq?
 
so fowlers mapper is pretty much this with a different name?
 
@Patrick the way I see it, the mayor difference between DDD and non-DDD style is actually the part you really like: immutability. And the part that it affects the most is the persistence. You end up needing a huge infrastructure there - either making a factory as a dependency for a mapper or going full repository-approach. While those have their place in huge projects, they just create pointless bloat in anything under 100k LoC
 
3:57 PM
@Patrick yea, that's actually not a repository at all. A repository is defined as something that exposes a collection-like interface.
 
@tereško I always found a simple Repository provided nice SoC, not over-engineering, even in small CRUD projects
 
@StefanoTorresi not according to fowler maybe. But it's a DDD repository
 
@Patrick that's just an interface. It is worthless
 
@tereško how would this be less bloated with setters? github.com/PatrickLouys/professional-php-sample-code/blob/…
 
@Patrick fair point
 
3:58 PM
@FélixGagnon-Grenier did you know that diarrhea is actually a shortened version of eau de derrier (however you spell that)… I am not shitting you… and yes, the pun's intended. now let me witness you mindblown and unable to tell if serious or not
 
@Patrick you seem to ignore the elephant-sized library in that class as a dependency
 
@Stuart which part of that is confusing to you?
 
@tereško you could also use PDO if that's your preference, I don't see how that is related to the topic?
it's DBAL not Doctrine ORM
 
@Patrick then why are you calling it "repository"?
 
@Patrick that's actually very nice code, I wouldn't change a thing.
 
4:00 PM
names are the means for the meaning
a mapper is a dependency of a repository
 
@tereško because fowler is not the authority on everything. the world has moved on since PoEAA and this is actually what most people call a repository
 
then lets go with Evans
page 135
 
@Gordon consider my mind somewhat blown
 
@Patrick just be cause most people refer to active record instance as "models" does not make them right
 
@tereško Evan's book is also out of date. He says so himself in the intro to Vaughn Vernons book and says that some things changed for the better through experience with DDD
and your link doesn't work (but I have a copy at home)
Anyway, gotta run
 
4:06 PM
strange how DDD people keep re-defining what "repository" is (because that's what you are implying)
 
4:35 PM
@tereško That is a really good question. I'm not sure why my IDE is doing that.
It looks perfect to me on my IDE.
 
it looks like you are mixing spaces and tabs for indentation
try enabling "show hidden symbols" in your IDE
 
I'll try that. Thanks.
What did you think so far?
@Danack I did end up bringing in Auryn after seeing how managing the dependency tree by hand in Bootstrap would be super lame.
Speaking of which...how do you usually define your dependencies? I made $injector global and recursively loaded all the PHP files in a directory. That seems not good.
 
hmmm.............
so, assuming you follow with the general index.php that requires a bootstrap file that in turn prepares the ground for launching the app, the $injector should exist only in the bootstrap file
 
@FélixGagnon-Grenier I did it like this...
 
ok. I don't understand what you mean by "I made $injector global" then?
 
4:44 PM
Just kidding. I didn't push that part from home. Fuck.
@FélixGagnon-Grenier In index.php I just wrote a function called autoload which took a relative path and recursively included all of the PHP files in that directory. For some reason, the files were indeed loaded, but $injector was not in scope.
So, I said "fuck it" and slammed a global at the beginning of each definition file.
 
well, the good part is that since yesterday you got composer's autoloader to work, you can kill that horrifying function and globals with fire, yes?
 
@FélixGagnon-Grenier Well, no. That function's only purpose was loading the Auryn and route definitions.
It was never for getting classes or interfaces.
 
so, you wrote that function instead of, like, $routes = require __DIR__ . '/routes.php?
let's take a few steps back, do you use fast route?
 
@FélixGagnon-Grenier I was using Symfony's routing component at the behest of Teresko.
I effing hate that router. Absolutely hate it.
 
I find that fast route is much simpler, which makes it a good way to learn the general concepts of routing
 
4:51 PM
I've written routers before. Granted they were closer to Laravel's but...
 
in any event, not sure what the function that loads auryn and routes was supposed to do, but why isn't the autoloader sufficient?
stop me if you already know it, but you can also include files through composer
 
@FélixGagnon-Grenier Because the autoloader won't load those files, will it? There are no classes in them. Only route instances and Auryn instances.
Can you do it with a regex or do you have to do it individually?
 
just beside the psr-4 property of the autoload
{ "psr-4": {}, "files": ["src/functions.php"] }
I generally have a function like function createInjector(): \Auryn\Injector {} that defines everything it needs
 
@FélixGagnon-Grenier But why add a line in Composer every time I add a new set of routes or Auryn definitions when I can just recursively include everything in ../DIC or whatever?
 
sorry if it seems I am suggesting that, I still don't understand what your route loading pattern is. keep in mind I am not completely masterful of symfony's router, I generally use the yaml routes definitions and load them in the code
 
4:59 PM
@Allenph did you look how it was set up in the example I gave you yesterday ?
 
See, that confuses me how people do that. Even with Auryn every controller might have wildly different dependencies...how can you acount for that in a config file?
 
Sorry, I want to know if FPDF have 96DPI or 72DPI=
 
Evenings
 
@tereško Yeah. I did. It was also very confusing for me. Because of what I just mentioned.
 
5:00 PM
I'm trying to create a pdf from image, I want that PDF Page size === Image size.
How could I reach it?
 
@Allenph tell auryn how to create any of them, and then let it work out what needs to be made?
 
Perhaps the answer is that there should be a DIC configuration for every controller as well, then all the router has to is ->make that class.
 
@MáximaAlekz one of those measurements is in inches, the other is in pixels.......what do you actually want to do?
 
Ahhh. I see. The definition is in the DIC, not the router.
 
5:02 PM
perhaps of help:
Nov 21 '17 at 21:28, by Danack
btw, this is an example file of how I configure Auryn with the simple class to pass the values into injector.
 
@tereško Since the entities should know how to validate themselves, suppose I have a setter method for phone numbers setPhone(int $phone), now, if I set a string to that phone number, PHP would throw an error to me because of the type mismatch, and I can't do a validation unless I have set the phone number.
So, do I do an is_int() before calling the setter?
 
@CoderDudeTwodee I would create a custom class: PhoneNumber
leave the validation logic in it
and, btw, phone number should be a string value
 
> Since the entities should know how to validate themselves
 
@tereško Why though? They are just numbers. Also, I am not taking country codes, and people in our place usually don't put dashes in between numbers.
 
5:10 PM
because "+44 800 048 8989" is a valid phone number
and so is "+1 (212)232-8294" or "1-866-475-0729"
 
They are, but the registration is not for people limited to our country. So, we can ignore the "+" part, and people here never use "()" or "-" to break numbers.
 
> "people here never"
bullshit
users always try to do something strange
4
think on how stupid is a average human, and now consider the fact, that half of them are dumber
 
There's no perfect way to validate phone numbers except for trying to use them. It's better to have bad data than no user at all because you rejected them over their phone number format.
 
Alright. I will just turn that to a string.
Sadly, my uni won't give me an SMS gateway and yet they want valid phone numbers.
 
Say nothing. Just hand them a list of perfectly callable numbers in a month that would have been rejected by your "perfect phone number" regex.
 
5:27 PM
@Danack Do you have an example of using github.com/Danack/AurynConfig/blob/master/src/AurynConfig/…?
To me it just looks like the abstraction is so thin it's not really worth it? Obviously it's not, but.
 
it's just a pattern of how I bootstrap an app....not an abstraction.
 
Static and using controller to display view? I thought these were both no-nos?
 
Nite all have a happy Friday lata all o/
 
@Allenph it's not static. Auryn creates the class and then calls the method. But actually static would be fine in this case, as it's really just a function any way.
> using controller to display view?
I believe people have made up the term "action-domain-responder" to cover it....I don't care. It works and it makes the application very simple.
 
So you do all your routes and Auryn definitions in a single file then?
 
5:39 PM
@Danack merging views and controllers is very useful, when you are making APIs
but in a normal application, if the UI logic starts to expand, splitting them becomes a necessity
 
@tereško If you're just spitting out JSON or binary files though your engine should be extremely simple. Why break the rules?
 
> I think it's much more useful to think of validation as something that's bound to a context - typically an action that you want to do. Is this order valid to be filled, is this customer valid to check in to the hotel. So rather than have methods like isValid have methods like isValidForCheckIn.
https://martinfowler.com/bliki/ContextualValidation.html

I will remember that.
 
single file per application yes. For my current work project where we have a 'frontend' - that renders html pages, an 'api' that takes and responds with json, and a separate 'admin' site, each of those has their own route file, and DI config file.
 
@Allenph what rules? You do not understand the Separation of Concerns
 
@tereško If you're spitting out JSON in the controller...aren't you doing more than controlling?
 
5:44 PM
 
@Allenph in simple non-mvc applications like Slim there is not much to a controller anyway
they are actually just functions that take a request and return a response.
if you need a complex UI you can compose that in that function.
 
And for me, they don't even take a request....they can take whatever parameter they actually need.
 
yea, in Slim IIRC you can even print output in them, but those are specifics to Slim, I think
the point is, there is no holy trinity involved.
at the end of the day HTTP is request->response. MVC was designed for native desktop applications with a long lifecycle. PHP becomes much simpler without all that. So no, there is no wrong in putting some HTML string into a response inside some function that takes a request.
 
That diagram to me suggests that I was right. I must not be understanding.

It was you that taught me to separate them. It seems to me that you would have the same (although probably less severe) problems with merging the view and controller even in an API. It would lend itself to doing strange state manipulations or DTO creations just for a specific view.
 
nothing in the UI layer should be aware of the internal workings of model layer
they interaction should happen only via services
DTOs are a persistence-level elements
 
5:53 PM
@tereško You're right. I keep forgetting about the services when I think about these concepts. Still new to me. Sorry I keep having to relearn that lesson.
 
2 hours in, and I yet to find a way to validate phone numbers properly.
 
@Danack How do you get these awesome classes? Can you lend me your eyes?
 
6:29 PM
@Danack I want convert RGBA image to pdf keeping its transparency. To sign another pdf
 
6:53 PM
What's for lunch
 
lasagna
 
lol
You two at the same restaurant.
 
eh, that could be fun
but nay, these were home made
 
You make it.
 
6:56 PM
I have a frozen dinner, lol
 
Fellas, fun question: Could you give a few examples for PHP bugs and/or unexpected behavior that exists in Windows that do not on Linux?
 
Is been a while since, I had pasta.
@MadaraUchiha rewrite rules. That could have been different Apache versions also.
 
@MadaraUchiha anything to do with stupid filesystems
I seem to remember something funky with passing around handles from child processes too, but I might be imaginging it
 
I once had a gf that knew how to cook the best lasagna. How I ever let go of that girl lol
 
@SalOrozco Maybe she "pasta-way"?
 
7:06 PM
@Allenph haha that is funny.
 
Maybe it's because he was penne-less
 
Whats a good book on unit testing.
 
@SalOrozco Unit testing is easy, there's almost nothing to it.
Writing testable code, however, that's trickier.
 
@MadaraUchiha then I shouldn't worry much about it.
 
Watch these, they are some of the best lectures on the subject on YouTube
 
7:20 PM
Tried reading the grumpy programmers cookbook.
 
I've been watching those 5 times each, and every time I've learned something new I've missed or was not knowledgeable enough to understand before.
 
@mad
@MadaraUchiha I will check it out.
I also want to learn more about data structures and algorithms. You know any videos for that?
 
Wes
@DaveRandom ikr dude what a crazy series lol
 
@MadaraUchiha phew, the very most things are identical on both systems, except perhaps some trickery with proc_open etc.
 
Wes
\o
 
7:43 PM
It seems like libphonenumber uses the singleton pattern. How do I inject that as a dependency if I am using Auryn?
 
@CoderDudeTwodee Worst case, you create your own wrapper around it and treat it like it isn't a singleton.
 
@MadaraUchiha Should I make a factory and delegate to the class?
Seems to work.
Now I see why Singletons can screw things up.
 
 
1 hour later…
Wes
8:53 PM
ba
 
9:04 PM
baa baa
 
baaaaaaaaaaaa
 
Wes
bo bo bo
 
… bob? :-P
 
Wes
i slept all day again
 
@Trowski did you see the update on the issue for crate/crate? tl;dr the protocol supports deallocation, but libpq doesn't expose, thus there's no way that PHP can reasonably expose it in any way other than what we already do. They appear to have bumped supporting DEALLOCATE up their list of things to do.
 
9:09 PM
@Wes Sorry.
 
Wes
not just you, i was doing other things. dont' worry :D
i can't do anything that just finishes at some point
this static analyzer thing is driving me crazy :(
i need to try a more heuristic approach
 
I've closed several tickets this week... I'm nearing a point where I can focus on code again. \o/
I need to clean my git repo before I do anything else though x_x I'm dreading that
 
define "clean"?
Is this related to SOAP in some way?
 
Wes
i need to start a new program but i'm keeping losing time on any kind of shit
<- greatest procrastinator on earth
 
@DaveRandom I suppose that makes sense, as DEALLOCATE is not standard SQL.
 
Wes
9:14 PM
i was supposed to start it at the very beginning of jan.... it's almost feb :(
 
Odd that libpq doesn't expose it though.
 
@Wes I'd argue that I'm greater, but I'm busy looking at cats on the internet and picking fluff out of my belly button
5
 
@WesNetmo I'd argue that I'm greater, but I'm busy looking at cats on the internet and picking fluff out of my belly button
 
@DaveRandom I...kinda...stopped...making regular commits when I started working on that landing page site that I was trying to create a redirect to. Plus a vendor has been working on the code for a different project, and I don't want to checkout another branch until they're done. There are also a couple of changes I made right to prod :X I'm fairly positive I copied them to dev though.
 
9:17 PM
@Trowski yeh it's weird, I considered working up a patch for libpq but to be brutally honest I cba, and it won't solve that guy's problem anyway because it would take ages for the change to be in a current release of libpq, then patch PHP, wait for that to be released... I just don't have the patience for that shit
which is completely the wrong attitude but... sue me
 
@DaveRandom I was considering pulling Promise\rethrow from around the deallocate query.
@DaveRandom Nah, I had that exact line of thought… lol
 
Well Bob suggested that we could trap the exception and use it to turn the dealloc callback into a no-op for that connection handle
i.e. gracefully detect when the dealloc fails and stop trying for future statements
does the pool recycle connections after n queries?
that would help, if you killed off a connection every so often, it would stop dead statement handles from building up on the server side
sort of like the way fpm recycles worker processes to help guard against memory leaks
@Tiffany ummm... you might be doing git wrong?
I mean my git workflow isn't great, but at least I have one (sort of) :-P
why is the vendor not working in a branch... in a clone?
 
lapse of attention on my part because I was focused on other project that had a deadline quickly approaching
 
Wes
btw @name on !!tweet should be prepended with a dot
 
true
 
Wes
9:31 PM
you can't create an abstract class when it only has one inheritor
"code that looks the same now, will unlikely look the same in future"
 
!!version
 
Wes
also every time you use extends a kitten dies
 
how's that for service
 
Wes
did it already? i like dave when he's not picking fluff out of the belly button
 
9:35 PM
I wonder if we should maybe insert a zwnj when the @mention doesn't target a resolvable username
 
Wes
why's that? can't it be just removed?
 
Like, if I were to write a message with @foo in it here, then the twitter handle @foo would get a ping even though it doesn't resolve to a user in here
if we put a zwnj between @ and foo, then it displays the same but without pinging randomers
 
Wes
i see
 
it's the same thing we do to stop you from getting pinged twice when I do this:
!!say hi @Wes
 
hi @‌Wes
 
Wes
9:46 PM
noice
 
@Wes Where are you looking at?
 
@DaveRandom The pool kills unused connections after a while. It would probably be easy enough to recycle them after so many uses.
 
Wes
and even if you do, you must inject them, not extend them
 
@Trowski I suppose the kicker with that is actually around prepared statements, though. I wouldn't want a connection that had an active prepared statement to be killed, then suddenly my Statement object is inexplicably unusable. Or are you storing the query data so it can be prepared on multiple connections?
 
@DaveRandom If there's an active statement around the connection is considered used.
The kicker there is that if you leave a statement around long enough, the connection might die and you won't find out until you try to use the statement.
 
9:54 PM
tbh this is such an edge-case, and specifically around a 3rd party that we don't officially support, that I think the pragmatic answer here is
 
@DaveRandom Yeah, I agree.
Are statements becoming invalid after a long idle time really a problem?
 
it's not like this is going to cause major issues unless you are doing something hella weird already, a typical application isn't going to keep more than a few 10s of prepared statements around, not deallocating them isn't exactly going to bring the server down with that extra few KB of redundant allocated resources on the server
 
@DaveRandom Right, but how long do apps usually leave statements around?
Is it surprising to have a prepared statement become invalid? I wouldn't think so, because if it were connected to a single connection rather than a pool it would happen.
 
Well in general in desktop apps, I will have however many prepared statements are needed to run the application and I will never destroy them until the app is closed. It rare in a long running application that you would have a single-use statement, and indeed that completely negates the point of prepared statements
 

« first day (2658 days earlier)      last day (2308 days later) »