« first day (441 days earlier)      last day (4521 days later) » 
00:00 - 16:0016:00 - 00:00

12:13 AM
@hakre Competition :P
 
yeee
The forgotten function in the ArrayAccess Interface:
public function offsetSetReference($key, &$value);
0
A: ArrayAccess in PHP -- assigning to offset by reference

hakreThis does not work with ArrayAccess, you could add yourself a public function that allows you to set a reference to an offset (sure, this looks different to using array syntax, so it's not really a sufficient answer): class Test implements ArrayAccess{ protected $_data = array(); publi...

gn8 folks
 
cya
 
@hakre night
and going to sleep too, so gn8 again ^^
 
12:39 AM
What exactly should a bootstrap be responsible for?
 
Orchestrating the application execution or doing everything that is necessary that that can be dispatched to a class
Or in short: Wiring everything together and kicking it off
 
@hakre which is why you commit early and often...
 
@CharlesSprayberry Or well. Wiring the essentials together and kicking something off that wires some more
 
1:07 AM
re ;)
 
Sleepless in $somewhereInEurope ?
 
bootstrap is the part of the application that comes first, so to say the place the PHP interpreter will find first.
yeah
it can actually be a transaction script if you use the webserver as frontend controller.
or application controller.
 
Would it make sense to split the various "wiring of essential parts" into multiple objects?
 
What do you think are the essential parts?
 
If you don't always need the object you don't need ot put them together for now
 
1:11 AM
And it's often very hard with PHP, because if you want to go that route, you first needs to abstract everything that PHP statically injects at first.
 
It's a little hard to answer that more precisely since what you need really depends on .. well what you need :)
 
Yeah it's really hard to say.
 
... like the Session, the Request, the cookie handling and so on
 
Well, I have a Directory object that I use to create paths for the file system. But, right now it is static and I hate it. It makes unit tests hard and now I'm stuck using that class
 
Bootstrap sample: raw.github.com/thePHPcc/bankaccount/master/htdocs/index.php (I keep dragging this project here but it's the best "demo app" I know to show off what I consider maintainable in a simple undesrstandable way)
 
1:13 AM
So, I want a bootstrap object that creates a non-static Directory object with the right paths set
And then a Autoloader bootstrap that uses the Directory object to setup class autoloading
 
Your autoloader doesn't need a directory object
your autoloader needs a Path if i remember correctly
All you need to tell it is where to look for the stuff. Not more (Right?)
 
Probably you can replace your Directory object with something that extends from SPLFileInfo?
And you just remove all static classes?
 
$ClassLoader = new \SprayFire\Core\ClassLoader();
$ClassLoader->registerNamespaceDirectory('SprayFire', \SprayFire\Core\Directory::getLibsPath());
Ah. That already looks nice (API whise, not what you put in)
$ClassLoader->registerNamespaceDirectory('SprayFire',$libsPath);
 
@edorian Well, I'm actually in the middle of refactoring Directory into a non-static object
 
Glancing over it i don't see a need to have that one the directory class at all
 
1:17 AM
I think the autoloader is the easier part.
Which part of your application actually needs a directory object?
These parts should just ask for it.
 
@hakre That's what this new git branch is for :)
Ok, I guess I need to go look at some things. Thank you for the thoughts
 
Having different warning levels in php code sniffer just feels like a colossal waste of time
Ether it's ok to have then don't say anything or if it's not ok then fix it...
Having 1200 "Warnings with low severity" is worse than not having any issues reported at all as it wastes a lot of time </rant>
 
hmm
which sniffs?
 
Let's for the sake of the argument say: LineLimit and AbsoluteLineLimit
 
hehe
 
1:31 AM
So you have 700 warnings stating "this line is over 80 chars" but your absolute limit is 120 chars
So why care .. ether it's ok to have 120 char long lines or it's not. End of story
 
are you using it in your IDE or in the shell?
Because in the IDE you will get the notice next to the line.
Low will be just something not that obstrusive
but error gives you something more hitting the eye
 
alias "git-push"="ant phpcs && ant phpmd && git-push"
 
no testing?
 
I've used it from the ide back in the netbeans days. pdt looks a lot nicer from what i can remember
Testing happens all the time anyways
ether I have a terminal running watch -n1 'phpunit' or I push the buttons in the ide every 20-30 seconds
But yeah.. it might not hurt
Which IDE does that nice phpcs reporting that you refereed to?
 
Eclipse does
I have a screenshot somehwere
 
1:36 AM
But then I'd still say: Let it be bright red. Because if it shouldn't be there it really shouldn't be there
If there are a lot of "small unobtrusive notices" then you learn to ignore them and whats the point of having them then
 
Well I think there is priority.
And you can group in eclipse by error levels.
e.g. you can disable certain levels
to first concentrate on the more grave things
That was quite fun.
 
Then I'll deactivate all the "not so important" rules until all the imporant issues are taken care off.
(Starting off with cleaning efforts: Maybe. But for the daily use case it annoys the hell out of me when people say "yeah that numbers should stay at around 1750")
What metric is that. Having 1700 warnings is ok but 1800 is a problem? :)
 
well actually that's the decision to not follow any standards.
and it's making the warnings useless.
What's needed is actually a better code-formattor.
Is there a sniff in phpcs for commented code?
 
And having some things as "errors" and some things as "warnings" suggests that it ok to have some "warnings" in there
There is a sniff for massive pear-style doc blocks but iirc no sensible one
Following that is, in my opinion, just a massive waste of everyones time, hurtful and overall it leads to poor code quality
 
yeah reading the docblock of that sniff
it's wrong in many places.
e.g. if the function name is speaking, it needs no headline.
same for parameters
they don't need a tag then.
so a well written function does not need a docblock at all probably
But I meant another type of sniff.
was just curious.
I have a little tool here that I can run over the codebase from shell.
it checks all files.
 
1:53 AM
And here is no need for repeating the variables names or the objects types :)
 
if those are text based, encoding is verified.
if they are php, it looks for commented lines of code
usage of var_dump and the like
if there is a die or exit.
also indentation and whitespaces.
same for XML files.
 
There is a disallowedFunctions sniff where var_dump can be included
There is something to check for die and exit too I belive but i don't see it atm.
And the indention checking sniff is quite good
 
looks strict.
with paranthesis and all the like.
 
Which I can accept since it's indentation and I tend to follow that closely. It allows for more indents than needed if one whats that
 
phpcs has really grown somehow.
last time I looked into the source I don't remember it that way.
 
1:59 AM
grown, proliferated, something
 
the quick parser I have is more or less line based.
 
But since the sniffs are what makes and breaks BC it's hard to argue that they should be leaned up more
 
you hook in simple routines that can operate on files.
 
It's fine the way it is.. just the docs are lacking
 
and can do even changes to the files.
the user can decide to accept the changes or not.
an idea I had is that you give a code checker a PHP file
 
2:02 AM
Auto formatting PHP code is something that never really works out. 98% are working (Netbeans has quite a nice one) but since it's never a php command line script they are bound to break at some point and cause isses
 
you put in how to bracket and indent this or that.
this file (or files) would be used for configuration.
the parser could distinguish between function definitions, class functions etc. pp.
and would read out the style.
space here or there
after each function a newline.
etc. pp.
 
Even if I had to configure it via xml I'd be very happy with a PHP tool that can format PHP code.
 
as it could already read the configuration php files, it can also read any other php file and compare against these values.
 
Just to be IDE independent for those tasks
 
sure I would use PHP itself here, because even in the eclipse DLTK, which is some sort of a parser for the code, it's not 100% PHP compatible.
E.g. that function with which you can tell PHP to not further on process the file as PHP file.
It's ignored. As well as some other things.
 
2:06 AM
Yeah thats usually the issue. If I'm honest for detecting issues something like: github.com/sebastianbergmann/phpunit/blob/3.6/build/PHPCS/… is good enough and for automated fixing it would have to be IDE independent for me to be really useful
The auto formatting of netbeans is a good start anyways. They do a lot of things right (imho) with the options the offer
 
auto formatting is always something delicated, because, it's automated, not always sane. It probably never could be.
With the indentation this pretty well works in the text based tool I have.
It calculates the steps used in indentation per file.
If there are mixes between tabs and spaces, there's a suggestion which one is the preferred way in the file and changes are suggested according to it.
 
Yeah
 
I need to take a look at netbeans because eclipse PDT autoformatting is non-existant.
I talked with sven kiera once about that.
It did exist in the past.
But its gone since 2,3 years.
If we write a php tool for formatting, he said he would do the eclipse gui :)
I wonder how suggested edits would look like in eclipse
 
diff view?
 
would be cool that a compare view is opened with the diff next to each other.
yeah
 
2:20 AM
All right. Time for me to go
Cya tomorrow (or later ;) )
 
cya
no going off as well
 
 
3 hours later…
5:30 AM
i have two tables credits and userTokens both have userid columns
now i want to fetch the data for same userid what i can do ?
 
5:51 AM
@root use a Join of some kind. Look them up.
 
6:25 AM
hey i have problem in cake php loging ?
can any one help me
 
7:09 AM
@AamirPathan What version of CakePHP are you using?
 
7:23 AM
0
Q: Implementing MVP in Web Applications

Levi MorrisonAs I understand it, MVP is a derivative of MVC where the Model and the View are loosely or completely decoupled, and the Presenter replaces the Controller and acts as the bridge between the View and the Model. This pattern seems more appropriate than traditional MVC in web applications (whether ...

 
@LeviMorrison factories?
 
@CharlesSprayberry Obviously, but HOW to implement it?
 
@LeviMorrison instead of injecting Model and View inject the factories needed to create the appropriate dependencies?
 
My original question actually used the word factory but I refactored my question a bit and that piece was lost.
@CharlesSprayberry I just can't see how I can know what view and model I will need before the presenter is instantiated.
 
@LeviMorrison You don't, you leave it up to the presenter to get the specific object from the factories
 
7:30 AM
@CharlesSprayberry It's making more sense, but it is still a bit fuzzy.
 
Unit test the factories to ensure the specific implementation is properly being returned. Assuming you are working off some Model interface than unit testing the Presenter shouldn't depend on a specific implementation but just some implementation of the right interface
$Presenter = new Presenter($ModelFactory, $ViewFactory);
$Presenter->beginPresentation();
// or whatever it is that you call
 
This is such an easy problem in an offline application because the view is already created when it calls stuff in the presenter. What view should I use? Oh, the one that sent the event, obviously. Oh look, it's already instantiated. Convenient. I'll just use that . . .
 
@LeviMorrison Great, only need one factory
 
@CharlesSprayberry Yes, and I'd call it main.
 
@LeviMorrison Whatever tickles your pickle
 
7:38 AM
(Un)fortunately, the web is stateless.
 
spent all day refactoring a static class out of my project
 
@CharlesSprayberry Good for you :)
 
141 methods, only 1 static. The PHPUnit test suite suite() function :P
 
@CharlesSprayberry Btw, while I think traditional MVC is garbage for the web, I'm beginning to think all of its variants are also garbage. I think I need to get some sleep and revisit the whole web concept with a fresh mind.
 
@LeviMorrison I think the important thing about "MVC" on the web is properly separating your business logic from your response
I like to think of it as Model-Response-Controller, I'm not sending a View back. You sent a Request so, I'll send a Response
Just the term View has connotations that it is something you should see...a lot of the time with websites or webapps it is not something you can see that is the response
 
7:45 AM
@CharlesSprayberry I'm really beginning to like RMR, btw: peej.co.uk/articles/rmr-architecture.html
 
8:29 AM
Hi,Can i user Functions inside function ?
0
Q: Functions in codeigniter

Dileep DilI have a model class that looks likes the following function block_user() { function is_in_blocked_list() { //line number 137... } function power_block() { is_in_blocked_list() // doing some operations } if (condition) { power_block(); } } But i am getting an ...

check this one..
 
 
1 hour later…
9:50 AM
@all hi any one there I have an issue regarding downloading
@all I have write the download method in which I have return the downloading url it work fine fire fox in windows machine but didn't work on safari I have check that in mac that why my iPad application is not able to download that file
 
how does facebook change the url without loading the page.. for example www.facebook.com/profile.php?sk=wall to www.facebook.com/profile.php?sk=info
 
10:20 AM
this room is dead
 
10:33 AM
yes right
bye all boring chat room .....
 
morning
@user994144 window.history.pushState("object or string", "Title", "/new-url"); => HTML5 History API
@user994144 It's Saturday morning, what do you expect? ^^
 
@NikiC will this work in all the browsers? was considering using session variables
@NikiC i see some users online.. may be they forgot to log out of this room
 
@user994144 No, will only work in newer browsers supporting the History API. For older browsers you would need to either fall back to normal page loads or use url#!something like URLs (like on Twitter)
@user994144 Yeah many people just stay logged in all the time ;)
 
10:49 AM
@NikiC ok if i use #!... how do i extract the value under #! using php?
 
:2244609 you can't, the hash isn't sent to PHP ;) Using #! URLs is only useful if you want to retrieve your data by using Ajax (i.e. you retrieve the URL using JS and then send an XMLHttpRequest to PHP)
 
@NikiC oh yes.. then how do i extract the value using javascript? that should be enough for me
 
@user994144 I don't know JS well, chat.stackoverflow.com/rooms/17/javascript might be a better place to ask. But it should be in window.location.hash or something like that ;)
 
@NikiC yip that's it.. thanks :) I don't have an excuse to take a break now
 
bonjour
 
11:35 AM
@gordon can I borrow some of your expertise?
 
@hakre dunno
 
I've been watching to the Misko Hevery videos and I like them. However I have one twist.
It's about the mutable global state to prevent.
I see how DI helps a lot and is preferable.
But I want (ideally) prevent these context/app/registry objects now.
As he suggests as well.
So at one point he talks about layers.
Taken some transaction scripts that just do the work.
And some of them need the database component, others let's say the filesystem component.
How can I inject them without having this global context thingy?
How can I establish the layers?
If I don't want to instantiate them with new inside the transaction script?
 
factories
create all that is needed for the whole lifecycle in bootstrap. create everything that is needed to require the specific request in a factory.
i think he has a blog post about it. let me see if i can find it
 
thanks.
 
11:41 AM
I know he differs between the domain objects and the creational objects this two pile of things, and I really like the idea.
 
yeah, it was eye opening for me
 
11:52 AM
Hmm, the ApplicationFactory seems so massive to me. But that might be just my perception I'm stumbling over.
At least the transactions need something to work with, so it must come from somewhere ;)
 
applicationfactory is kinda like the bootstrap so naturally it is somewhat bigger
if you dont like having classes for each possible request, you can also map your routes to closures, like silex does it. this will keep factory count low.
 
That's the next step, because I'd like to understand the interfacing to UI Robert Martin speaks of in Architecture the Lost Years but I could not watch the whole video yet.
 
@hakre didnt get to watching that yet. video didnt work for me when i pasted the link here
 
I have the general feeling as those interfaces are generic, they ideally should pass value objects into the response interface, but probably what's now the "bootstrap" which will negotiate between the application logic and the UI can mediate between those.
I have a very old PHP application. What I like with these old scripts is that the routing is not part of the application by nature as apache / .htaccess takes care of that.
All these MVC frameworks around make routing so specifically tight to the rest.
These standard problem "how to build a URL".
for the response.
With oldskool PHP scripts I did this with relative paths which works quite well.
But those are directly interfacing with the browser UI, so HTTP is the interface.
So but something different now regarding factory.
Let's say I have a library.
And it creates objects of specific types which are all of a general type.
Is it bad to offer a static function on the "base" type that creates the concrete types based on the value passed into it?
Or should the library offer something so it can be more easily integrated as well?
But those objects would probably count as value objects.
So probably not really an issue.
thanks @gordon
 
i avoid static methods and i also avoid having factory methods on objects that are not strictly creator objects
 
12:03 PM
Need to pick some cream for the cake, shops are closing earlier today.
 
you are welcome. have fun and get good into the new year
 
you too.
 
thanks
 
12:46 PM
@Gordon nice read, thanks
 
Good afternoon
 
hey @Donut :)
 
Hello @NikiC
 
@Donut Still can't change your name? :P
 
Nope :(
13 days left
 
12:59 PM
:P
You poor donut :P
But at least donuts are tasty :)
 
hi @NikiC, @Donut.
 
@NikiC Yeah :)
Hi @hakre
 
1:18 PM
would it make sense to backport namespacing to PHP 5.2?
 
@ChristianSciberras huh?
 
I suspect the reason most CMSes don't do namespacing is because of breaking support with PHP <5.3
 
And you want to do what?
 
What do you mean by "backport namespacing to PHP 5.2"?
 
1:21 PM
PHP namespacing works for 5.3>= only
 
yes
 
my point is, since 5.2 is pretty much the standard PHP version on most hosts out there, it would have made sense to slate namespacing for 5.2, no?
 
You mean like ask PHP whether they would like to backport namespacing to the EOLd PHP 5.2?
 
@NikiC Fun fact:
Two days ago, I installed CentOS 5.7 on a server...next I proceeded with installing LAMP stack
php -v -> PHP 5.1
I was like WTF?!
 
yeah, Linux has those problems ^^
That's the nice thing about *BSD, you usually get the newest version within one or two days of the release.
 
1:27 PM
Guess what? HostGator still thinks CentOS 5.5 is da trend.
 
Change hosts :)
 
Of course, I have my ways of getting PHP 5.3 on my server running
But not everyone can do that.
@NikiC Yeah, wish everyone did just that.
Too bad our most modern clients are still running on PHP 5.2
And what am I supposed to tell them? "You can't run my code because it's PHP 5.3?"
They'd reply "but wordpress works on <5.3!!"
 
@ChristianSciberras yeah ^^
Tell them that PHP 5.2 has known security vulnerabilities and thus their server will get hacked and they'll be really fucked up and loose lots of money ;) Or something like that ^^
 
My real problem is this; the framework I'm building is mostly tested by those people. I'm finding it hard to introduce good practices, or indeed features like namespacing to my framework exactly because if I do, it will die out.
@NikiC Some of them are still running PHP 4.
And some of the code was written by a colleague of mine.... mysql_query('SELECT * FROM stuff WHERE cat='.$_GET['cat']);
Wonder why they haven't been hacked so far. Probably the fact that they're marketing websites / splashpages might be a factor...
 
@ChristianSciberras Actually officially it does, but all core devs use PHP 5.3. So it's only roughly tested for PHP 5.2. Tell your clients the nifty details ;)
@NikiC And PHP 5.3 is much faster. I really slapped my own butt that I have not switched earlier.
@ChristianSciberras To backport Namespacing in PHP 5.2, prefix the classnames.
You can still introduce good pratices then.
 
2:08 PM
Entered the C++ chatroom. Asked some question about C => flamewar against C. Mentioned PHP => flamewar against PHP. Great.
 
underwhelming :)
 
Uh, seems to be a strict C++ chatroom ;)
I guess if you ask about flamewar, they will flamewar against flamewar ;)
 
Well, as PHPeople we have a long history of dealing with people that don't know your language and ask about javascript or (My)Sql because "I want to do that in PHP". We just got very good at dealing with the masses
To reach the point in C++ where you have an issue with a database query you have to sort of know what you are doing already
 
That's a good example.
I mean PHP is somewhat a script interface to C libraries.
And a consumer of CGI with some knowledge about HTTP.
@NikiC: STUPID has a nice play: Singleton at start and Duplication at end.
 
@hakre In the sense of more important less important?
 
2:21 PM
No in the sense, if you start with Singleton you'll end with Duplication in the end.
 
@hakre :D
 
@NikiC: Typo: points in greater detail int the following int => in
And probably KISS is better coined as Keep It Simple, not Stupid!
really a nice article, @NikiC
And that's something I have experienced as well: nikic.github.com/2011/10/23/…
However if you need another token recognization strategy (like longest match wins), it's not possible. preg will return the first group that matches.
 
@hakre Longest match wins seems evil to me ;)
 
2:37 PM
typical lex behaviour.
 
@hakre Still don't like it ^^
 
And I like the growing token optimization.
class DocblockLexer {
private $regexLex = array(
'[{][{tagchar}][}]' => 'escape_at',
'[{]{tag}[}]' => 'inline_tag',
'[{]{tag}(?={s})' => 'inline_start',
'[}]{1,2}' => 'inline_end',
'{tagchar}-?{nmstart}+{s}?' => 'tag',
'[@\\\\]' => 'tagchar',

'{nmstart}+' => 'word',
'[.,;:!?]' => 'punct',

'[a-z]' => 'nmstart',
'[a-z0-9-]' => 'nmchar',
'[*]' => 'asterisk',
'(?:{nl}|{s})' => 'ws',
'(?:\n|\r\n|\r|\f)' => 'nl',
'[ \t]' => 's',

// ------ TOKENS: ------ //

'^/\*\*' => 'CM_START',
'\*/' => 'CM_END',
Incl. Macro support.
And you can formulate additional "regexes" with names later on after first lexing.
 
@hakre Don't quite get it.
By the way, I just had an incredible thought
If you teach PHP the right way you don't need to explain most of the language
 
There is some truth in that sentence.
 
2:53 PM
hi all..
@hakre hello...
 
hi
i need some help in getting php mail function to work on a fresh linux VPS
 
hi @Saurabh, @nivanka
@nivanka: The mail function might just work, but the fresh VPS might not have anything to further on process mails.
 
i am not sure
I installed sendmail as well
what are the configs I need on the php.ini
 
Are you using a specific distribution?
If so which one?
 
red had
*redhat
there are no mail function directives in the php.ini
 
3:35 PM
@nivanka , are you sure that you have correctly set up sendmail ?
can you mail yourself from console ?
 
3:52 PM
URL design question:
I have a groups which contain group members.
So to begin with:
/group/:id is a group
What URL would you recommend for a particular group member?
 
00:00 - 16:0016:00 - 00:00

« first day (441 days earlier)      last day (4521 days later) »