« first day (1507 days earlier)      last day (3423 days later) » 

1:00 PM
@argentum47 hence: Rails has nothing to do with MVC
 
@FlorianMargaine so should I not use it sir?
 
use what?
 
@FlorianMargaine sure thanks
 
@FlorianMargaine Super Globals
 
1:00 PM
I don't know. Do you know why it's a bad API?
 
@FlorianMargaine no sir, I was asked to follow that tutorial.
 
@argentum47 besides, you have to remember that Rails was never intended to production-stage. Instead it was created as a rapid-prototyping framework. And it's quite good at that. Problems start when you attempt to create something larger.
 
@FlorianMargaine Do you need to implement something in order to use SplEnum?
 
@HassanAlthaf stop calling people "sir"
@Naruto php 5.3, afaik
ah wait, my bad
you need pecl/spl_types
 
@FlorianMargaine well, what should I call then?
 
1:03 PM
don't call
see how other people here discuss
 
Guys, what is a good way to organize your data/code to be able to make data visible to some users and not visible to others. For example there are different levels of visibility (the people are in groups with different permissions) and you have to check that, where should that happen?
 
^ vague
@IamZesh well, that's ok, but what is your issue
 
But all the 6-7 clients we have are having us build website using rails. like hipchip.com therealreal.com
 
Ok for example you have people that are connected to you in the application and people that are not. People that are connected to you should see all your posts but people that are not connected to you should see only your public posts
Oh, wait, I am an idiot
6
 
@RonniSkansing Hey, I'm following that tutorial, but I am unfortunately not having any idea why to use 'HTTP' in Composer. Can you explain the use of it to me?
 
1:05 PM
@FlorianMargaine mm.. Not installed on the server.. Just asked my supervisor if it's possible to get it installed, but he said no.. So go back to the abstract class then? :)
 
@argentum47 those look like "business card" sites. Not really an issue at that scope of size.
 
Umm... Scope of size meaning large ?
or not that big
 
bad wording .. yeah
 
There are websites larger than these?
Oh, my bad, certainly
 
Guys, I seriously am in need of help.
 
1:10 PM
twitter facebook google ..
 
what you have there is a business card site and a standard shopping cart site
those ARE small sites
 
Suggestions how I can 'calculate' between 2 objects? I have a check_in and a check_out field : But when I do: <td>$row->check_out - $row->check_in</td>
I receive : 2015-01-18 - 2015-01-17 >< So its not doing the calculation.
 
they tend to have about 1 & 2 month development time respectively
 
Wait, this might come as a surpsrise, but the other people of our company have spend more or less 6 years on these.
 
@Naruto yeah
 
1:12 PM
maybe 3 or 4 atleast
 
0
Q: MVC: client app architecture to connect 'client' code and resources code

Iam ZeshI am writting a little php app (MVC) connecting to a CMS (an external website on which I have no control). The goal of the app is to perform CRUD actions in the CMS on behalf of the user, like creating / deleting / updating pages. In my app, I have come with two distinct functionalities: - som...

 
and actually, even for that shopping cart the code probably ended up like huge pile of spaghetti
 
@Duikboot you are trying to do calculations in the view?
 
1:13 PM
( It's just a WP plugin ) sssjt ( don't tell anyone ) And yes, actually it is.
 
@Patrick thank you
 
@Duikboot it should be more like this <td><?php echo $row->check_out - $row->check_in;?></td>
 
@Julo0sS then get a real server...
 
So which frameworks are better? PHP's or Java's or Scala's
 
1:14 PM
no framework is perfect
 
@ziGi This is how it looks like: paste.jesse-obrien.ca/18EJ
 
@argentum47 it is like asking is a Swiss knife better than a hammer
both are good in different situations
you can hammer stuff with a Swiss knife
 
@argentum47 no framework is best framework
 
but it won't be as effective as with a hammer
 
:D
 
1:15 PM
something that is production-stage. I guess that's why ruby rails are not used in Enterprise in place of Java and all
 
@Duikboot ah that's easy just make it like this <td>". $row->check_out - $row->check_in . "</td>
@Duikboot you are working in Amsterdam, right?
 
@ziGi ( That is not working :p )
No I am working in BE.
 
ah ok
 
But im actually just a front-ender :P
 
to be honest
what you are doing
should be ok
 
1:17 PM
Is ugly
Im not a fan. But ok :) I should split up the thing into a template file or so but I need to do the calculation :P
 
well that is not a good solution
usually it is much better to use sprintf
 
Hmmm what about doing the calculations before the loop is that possible?
 
sure
 
datediff or so
 
are check_in check_out dates?
yeah
just do it in the SQL querry
SELECT DATEDIFF(check_out, check_in) AS TotalChecked, ...
 
1:23 PM
I wonder why the ruby and rails books are 4 times pricey. :( . Its inhuman.
 
Yes they are 2014-11-20 09:51:10
 
and then in the print part do $row->TotalChecked
 
@Patrick thank you for your link but my question is not so much about MVC (I mean the app is built on a MVC framework) but more about how to organize the code and those 2 aspects, ie client and resource parts
 
@HassanAlthaf, did you figure it out, I did not fully understand where you where stuck?
 
@IamZesh what is client part? What is resource path?
 
1:24 PM
@RonniSkansing I cannot understand why to use HTTP.. like whats the use of it?
 
@tereško I posted my question on SO
 
Tried it this way: paste.jesse-obrien.ca/18Fo
 
ok one moment
 
@ziGi I called client the part that interacts with the CMS
 
1:25 PM
@ziGi Or just end the php tags and write normal html whilst adding in the minor interpolations... 3v4l.org/cGtnT
 
@ziGi the resource part is more about manipulating the resources like creating a new page
 
But that results in nothing :D The SQL querry I posted. I like it more when the calculation is done in the query.
 
@HassanAlthaf it is to isolate and incapsulate the code that deals with globals (because globals are bad). So instead of using methods like header(..) and globals like $_GET, $_POST, you instead use some class (like the request / response). So no echo out content, in the tutorial instead $response->setContent(..)
 
@Jimbo yeah, that's a solution but not a good one
 
@ziGi Why don't you consider it a good one? You interpolate the smallest changes so you have to do less in the long run
 
1:27 PM
@IamZesh that part should be some sort of files generator right?
 
@RonniSkansing Oh I see, thanks. And what about this thing: github.com/PatrickLouys/no-framework-tutorial/blob/master/…
 
@ziGi yeah
 
@Jimbo because in general I find it a better idea to make the DB do the calculations
 
@RonniSkansing so when I use $_SESSION should I still use session_start() methoD?
 
@Duikboot it is not about how you like it better
 
1:28 PM
@HassanAlthaf, no instead you have a class that takes care of it
 
@ziGi But then you start having to do in-db logic like "what if it goes less than 0" etc
 
but it is about what is a better practice
 
@ziGi I thought about having my app being RESTful, in a way that resources could be manipulated by it
 
Have you an idea what might be wrong with my query?
 
@RonniSkansing thats nice, but I don't get routing either. And I cannot even install it, i am trying to do it since 15 minutes now..
 
1:29 PM
@ziGi the thing is that resources and the actions on them are all using the basic client code (which is the part interacting with the external CMS)
 
@Jimbo no you don't, you do it when returned (if you have to). If your back-end is properly implemented, no such checks should be necessary because you wouldn't allow such errors
 
@HassanAlthaf the router is a class for setting up routes. It will act as a front controller, a main entry for all and every request. Did you add it to your composer.json and do a composer update
 
@IamZesh well isn't the CMS basically just used to populate the DB?
 
@ziGi so it seemed to me that those should be distinct because they perform different tasks, they seem to be at different levels
 
@RonniSkansing I did, composer update thing is saying its not found.
 
1:31 PM
@ziGi but the CMS is external to my app, I have no control on the CMS, my app aims at connecting to the CMS and performing the tasks allowed on behalf of the user
 
Dang this composer is amazing @RonniSkansing
 
@IamZesh sorry I got lost
What is the purpose of your app
 
@ziGi so I have this:
user -> app -> cms
my app aims at being some kind of client
 
and what should the user do with your app
generate sites?
 
ie providing the functionalities of the cms to the user
create pages
yeah
yes
 
1:32 PM
ok, so I guess you would have some templated files that are going to be available to the user through your app
and the CMS is going to be used to hold the specific site data and the template used by a specific user?
am I getting this right?
 
so in my app I have two functionalities, the part that handles the communication with the CMS
 
is the user going to have access to the generated page resources
 
and the one that presents the various actions that the user can operate on the resources
my question is how to organize those 2 in my app
 
I see
well I have never done something like this
so I am not sure if my opinion is going to be valid
 
ok
 
1:34 PM
but if your app is completely RESTful
 
yeah I would like opinions or advice so anything is welcomed
 
you still should split it in modules
so if one part is generating resources
and the other altering data through the CMS
this is quite an obvious separation of concerns
 
yes
 
if you split it in two
then in the future you can reuse
 
Anyone happen to know Doctrine very well?
 
1:36 PM
the resource generator
without having to bind it to the other part
 
but should the 'client' part (interactions with the CMS) should be a manipulated via a controller?
and the resources, like a Page
 
ah well
 
should manipulate this controller internally in the app
 
that depends how you are willing to build it
no
there should be a way to access
the client part
via a URI let's say
 
humm
I mean the user should not have control over the client part
 
1:37 PM
yes
 
I mean the point of the app is to take care of this
 
@HassanAlthaf did you get it fixed
 
@RonniSkansing no man, I did this in require part:
 
so the client would have the Pages resources via the PagesController
 
"nikic/FastRoute": ">=1.0.0"
 
and the PagesController (or the Page Model, what do you think?) should use the client for the various CRUD operations
 
If you are very familiar with Doctrine/database design I could use some help @ stackoverflow.com/questions/27209909
 
check this one, it would give you a good overview of what you want
 
Sweet I figured it out @ziGi the right query.
 
@ziGi but I don't want to build an MVC app per say
 
1:40 PM
you shouldn't
but your logic should be the following
 
ok
 
1. index.php - bootstrap the app initialize some necessary classes
2. Router class takes the URI and determines what is required from it (Create, Read, Update, Delte)
3. Router calls appropriate controller if the user has access to that controller (authentication)
4. Controller calls appropriate Service layer (which is basically the brain of the business logic)
5. Service creates a Domain Objects and Data Mappers so the Data Mappers know how to extract or persist data to/from the Domain Object
6. The domain object is converted in the service to an output which is returned to the controller
more or less that is the logic
 
@ziGi why would a "router" be calling classes ?
 
@ziGi Have you an idea why my 'totaalPrijs' is not being calculated? :) gist.github.com/duikb00t/24d23eb1b0edcc1b79b0
 
it's not a dispatcher by any change, @ziGi ?
 
1:45 PM
@tereško you are right
there should be a dispatcher
my bad
the router just parses the URI
 
also, why would "controller" be rendering the response ?
 
well because it is a REST
you don't need views
 
@ziGi thank you but I get this part
 
well at least that is how I do it
why do you need to make a view for a simple json output?
 
1:47 PM
my question is how to build over this
 
@tereško And every time I read your name I still read: c2.staticflickr.com/6/5283/5317115280_3714efb4d7_z.jpg instead of Teresko :p
 
@ziGi I guess all your responses are an empty body and a 200 header
 
how I can connect the two different functionalities
 
@IamZesh define "connect"
 
@tereško well if you need to return data?
 
1:48 PM
should the client be a trait used by the Page model?
 
@IamZesh ?
trait
 
yes
 
if "trait" is the answer, you are asking the wrong question
 
I think he is confused
about how things work
 
I don't know the answer
that's why I am asking
:)
 
1:49 PM
he is asking how to access one controller in a part of his application through a separate part of his app
 
@IamZesh what do you mean, when you say that you want to connect two functions ?
 
I am asking how to organize those 2 functionalities
the one that interacts with the CMS, the one that is like one level higher, managing the resources, like a Page, in a RESTful way
all of this inside of my app
 
I must be exceptionally dense today .. I still have no idea what he means by "connect"
 
I think he's asking how to organize his logic so he has 2 modules that do different things (creating web page files) and generating content and how one module can access information from the other
that's why he thinks he should use traits or something
 
1:52 PM
exatly
you got it @ziGi
 
those two methods should be performing the same service-call
 
I mean the 'client' module would connect to the CMS and instruct it to create a page for example and the 'Page' module is available to my user
 
@IamZesh I am not sure if I am correct but usually I would have a FilesService that creates files and DataService (this is a bit general) that returns some data so the FileService calls the DataService when it needs data
look at them as two separate files
 
.. namespaces
 
yes, on the other hand that too
 
1:54 PM
so I should use services?
like a Client service, that would be used by the Page model?
 
@ziGi FIlesService is not really descriptive. Why no call it FileReader, FileWriter or something else that describes exactly what the class does?
 
but the app is not working on files
 
@Patrick true, but because I am not sure of the nature of his app I am not able to make such a prediction
 
it is connecting to the external CMS and submit forms
 
@IamZesh , this might help: stackoverflow.com/a/25709651/727208
 
1:56 PM
and receives responses etc
 
@IamZesh Maybe this helps. See FilePageReader. This class is responsible to return the content of a page. It could also be a DbPageReader for example. There is an interface so the client code doesn't care where the page actually comes from. If this is too confusing, start at the beginning of the tutorial
 
@tereško is it possible that a Service makes a call to another Service to get some information or is it more logical to call the same Domain Objects and Data Mappers to obtain the same information?
I am a bit confused
 
@ziGi Don't treat this like MVC where you can only have Controller and Model classes. It's just a PHP class. Follow SOLID and make as many classes as you need
 
Ok I see
 
@ziGi answer to that question depends on the phase of moon ... at least in my case
 
2:02 PM
haha
I was just wondering, so I make an EmailSender and then ReminderObject, ReminderMapper, EmailContentBuilder so the mapper populates the ReminderObject which is then used by the EmailContentBuilder to fill in a template with the data and then the EmailSender uses the EmailContentBuilder to take the prepared email content to send it to the appropriate receiver?
 
I think the best option is to use a DI container for creating services (yes, that means that services get initialized outside the controller) and then you use DIC's functionality to share instances between services.
 
@ziGi ReminderObject? $nameString? $countInteger?
 
But that whole scenario depends on the whether you have a DI container and whether it can actually provide such functionality
 
@ziGi I don't like entities in my templates. I used to do that and it resulted in a lot of work when an entity changed... I prefer to return an array from my service that is used in a controller instead
 
@Patrick it is an object keeping reminders
 
2:09 PM
@ziGi so the others are not objects?
 
how would you name it?
true
 
@ziGi Reminder?
 
yes
ok
 
^ that was the suggested name
 
Sure, let's down vote a cw answer because it dares to suggest using an XML parser instead of PCRE ... heresy!
 
2:10 PM
@Patrick I always make the mistake to name Domain Objects (SomethingObject)
but that's a nasty habit I have to get rid of
 
@ziGi EmailSender should not take a contentbuilder imo, just pass in the content as string then you can use it for other things too
 
@Ja͢ck Well you are suggesting simplexml_load_string which sucks so there is that :P
 
Do you think it is a good idea to make an Email object that has all the headers (sender, receiver, body, etc.) that the EmailSender uses?
 
and do you really need a Reminder entity here? isn't that a bit overengineered?
 
@PeeHaa haha, granted .. i actually have seen a trend; it goes like "hmmph, bad question: -1 ... somebody actually answered? also -1!"
 
2:12 PM
Well it has some business logic when (creating updating) so I am reusing the object
it is more or less a container so the mapper knows how to populate it
but you might be right
I can just pass the result from the Mapper
but then I am passing around array
and it is not clear what data is being processed
 
That's one thing I don't really like about data mapper
Or, at least, my understanding of it.
 
I've always wondered, aren't Mappers tied to Domain Objects since they need to know the structure of the DO to be able to populate them
so the only reason I see for a DataMapper is to remove the information extraction/persistence from the DO
Although I am still hesitant on the idea of Entities/Domain Objects
I use them interchangeably in the moment
I read in PoEAA that if the application is not that big, there can be a single DataMapper which can be split in separate mappers when the time comes
if you application is not really big
 
@ziGi look at the last chapter I wrote. You don't always need entities, mappers etc...
 
Ok thank you Patrick
 
guys,
Open/closed principle, how can you avoid modification of classes, although allow extension to it?
Open/closed principle
“software entities … should be open for extension, but closed for modification.”
 
2:33 PM
BTW have anybody seen @DaveRandom yet?
 
Today, or... ever?
 
Last couple of days :P I got some texts from him last friday (probably doing that drunken island person thing again), but haven't seen him after that
 
texts or sexts?
 
sexts
 
@PeeHaa we lost him ? :O
 
2:36 PM
@ziGi this is what all my domain objects inherit: gist.github.com/teresko/4f09e3ed351bcb19d4fe .. that way you can populate the domain object without depending on the precise structure. But in general - yeah, mappers can only persist domain objects which implement a specific interface.
 
I wrote another long email to internals ^^
Here's my email about static classes: marc.info/?l=php-internals&m=141744442015888&w=2
 
@PeeHaa I think he's avoiding you…
 
@PeeHaa You guys have eachother's phone numbers?
 
@tereško yes, interesting, just one quick question, shouldn't the method be $method = 'set' . ucfirst($key);
 
@AndreaFaulds why you write he’d i mean ’ is it intentional ?
 
2:39 PM
I mean don't you use camelcase
 
@FlorianMargaine :)
 
@ziGi in php both class and method names are case-insensitive
 
Never saw this error in my logs: mod_fcgid: read data timeout in 90 seconds, referer:
 
Ah, true, I always forget about this thing :/
 
Is there an easy fix for that?
 
2:39 PM
@obiNullPoiиteяkenobi Fix your browser's encoding settings...
 
My colleague is arguing with me that I should rename EmailSender to EmailMessanger and instead of extending Sender I should extend Messanger. What do you think is he right? He said Sender is not descriptive enough.
 
@ziGi is it namespaced?
 
no unfortunately
actually it is
but with the weird '_' as proposed by ZendFramework 1
 
Maybe the namespace should be renamed.. it is a cascading challange. If the refactor of the class name and the parent is a quick fix and you think it adds value, do it. Else consider if it really worth spending time arguing over
 
I have just created the interface and classes
 
2:50 PM
I hope you meant EmailMessenger and not EmailMessanger though
 
so it should be done within a minute
@FlorianMargaine yes it's a typo
 
Hmm
I'm wondering if, for bigints, I should write my own implementation of the arithmetic instead of trying to make LibTomMath work
It wouldn't be blazing-fast, but does it matter? If you need that, you can build PHP to use GMP instead.
 
mod_fcgid: read data timeout in 90 seconds is there a max I can set it to?
 
@AndreaFaulds no.
 
@NikiC ok :p
 
2:53 PM
:D
 
@Patrick tbf, I call array properties either whateverArray or whateverMap depending on whether they're ordered or associative, to differentiate them from eachother and custom collection types.
 
Guys,
Anyone has any experience with:
 
I'm trying to test the native-tls branch for the RFC. I'm slightly confused by the instructions - do I really need to alter the m4 files of any extensions that I want to compile with native-tls to include "-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"? Is there no way to pass that in as a compile option?
/cross-posting ftw.
 
lol, someone here might have some experience.
 
@HassanAlthaf well, @NikiC has some experience with it
 
2:55 PM
^^
 
@NikiC bro, are you active?
 
@FlorianMargaine thanks.
@FlorianMargaine isn't he the creator.. lol
 
Actually I heard he's got completely amnesia and doesn't remember anything about it.
 
@NikiC You know, we already have our own bigint addition and subtraction implementation in core, right?
 
2:56 PM
@Danack Maybe pass it via CFLAGS to ./configure?
 
@NikiC
@NikiC I defined a route in the FastRoute, but how do I access it?
 
@AndreaFaulds You mean for dtoa/atod?
 
@NikiC No, I mean alphanumeric increment/decrement
 
@HassanAlthaf stop pinging him, you're very rude.
 
2:57 PM
@HassanAlthaf What do you mean by "access it"?
 
Like, urm.
 
@NikiC $ php -r '$x = "a" . (string)PHP_INT_MAX; $x++; var_dump($x);'
string(20) "a9223372036854775808"
 
return [
	['GET', '/', ['AccountingSystem\Controllers\Homepage', 'show']],
    ['GET', '/another-route', function () {
        echo 'This works too';
    }],
];
 
@AndreaFaulds lol - yeah, but that's only bigint increment / decrement ^^
 
If I basically goto index.php, isnt it not supposed to call the show() method in HOmepage class
 
2:59 PM
@NikiC True.
 
@NikiC thanks that worked....there still ought to be a better configure option...
 
$routeDefinitionCallback = function (\FastRoute\RouteCollector $r) {
	$routes = include("Routes.php");
	foreach ($routes as $route) {
		$r->addRoute($route[0], $route[1], $route[2]);
	}
};

$dispatcher = \FastRoute\simpleDispatcher($routeDefinitionCallback);

$routeInfo = $dispatcher->dispatch($request->getMethod(), $request->getPath());
switch ($routeInfo[0]) {
    case \FastRoute\Dispatcher::NOT_FOUND:
        $response->setContent('404 - Page not found');
        $response->setStatusCode(404);
 

« first day (1507 days earlier)      last day (3423 days later) »