|
Gnack posted:Ah okay, thank you. I did wonder if that's what he was getting at. I was hoping to avoid that but it makes sense so I think I'll go for that approach. Thanks both of you. Sorry, I was suggesting that functional programming makes things easier to test. isLocked() probably does't make sense to take any parameters, but return a boolean based off some property on the object. Having a getter/setter for date would help. Basically, php:<? // Create a date that's in the future. $date = new Date(time() + 3660); $mock = new MyMatchClass(); $mock->setMatchTime($date); $this->assertTrue($mock->isLocked()); // Subtract enough time to be in the past, and set matchtime $date->sub(DateInterval::createFromDateString('4000 seconds')); $mock->setMatchTime($date); $this->assertFalse($mock->isLocked()); ?>
|
# ? Feb 4, 2014 04:53 |
|
|
# ? Jun 7, 2024 18:19 |
|
spacebard posted:Sorry, I was suggesting that functional programming makes things easier to test. This really is the opposite of how I was thinking, and it makes perfect sense thanks. Shows you just need to be creative sometimes.
|
# ? Feb 4, 2014 06:46 |
|
PlesantDilemma posted:Anyone written an Excel file using PHP and have a recommendation on a library to use? This PHPExcel is my best find but I thought I would ask here too. Depends on your needs. If you're making some kind of complex spreadsheet with calculations and cell references and what have you, it'll work just fine. There's a big fat stack overflow answer with alternatives, but PHPExcel is often the go-to library in my experience. That said , PHPExcel tends to eat around 1kb of memory per cell, last time I used it, which is obviously a big problem if you're trying to say, export 100 columns and 10000 rows of data. Alternately, if you're just exporting craploads of tabular data, you can just create a blank HTML doc with a table in it containing your data, and name it .xls. Excel will pick that up, complain about the formatting, then open it. It sounds like a hacky workaround, butit's surprising how many systems make use of this trick to get around working with the xls format. An additional advantage is you can process say, 10 rows at a time and output the content to a file, so unlike PHPExcel you don't have to have the entire file in memory, which lets you output as much data as you need.
|
# ? Feb 4, 2014 12:04 |
|
v1nce posted:Depends on your needs. If you're making some kind of complex spreadsheet with calculations and cell references and what have you, it'll work just fine. There's a big fat stack overflow answer with alternatives, but PHPExcel is often the go-to library in my experience. We've been doing the html-as-fake-excel thing but customers complained because apparently Excel on mac wouldn't load the file. Or not load it correctly or something. The memory overhead sounds like a bummer but our reports aren't super huge so it should be fine. I'll have to add in something to track memory usage when I use it. Thanks for the tips I'll check out that SO post too.
|
# ? Feb 4, 2014 19:21 |
|
I'm using Laravel for a project I'm working on and I'd like to start using LESS to make CSS a little easier to maintain. I'm wondering if anyone has some pointers on decent asset managers for Laravel that will take care of auto-compiling the LESS for me? Preferably I'd like it to autocompile the LESS to CSS whenever it picks up that the LESS file has changed.
|
# ? Feb 4, 2014 23:56 |
|
I haven't found a good asset manager for Laravel yet, but I've gotten pretty good results setting up a watcher and some build tasks with Gulp (formerly with Grunt, but I find Gulp a lot easier to work with). Here's a quick overview, and a more in-depth video tutorial. If you mean a PHP-only LESS compiler, the only one I know of is lessphp. It's functional enough, but slow. Not an ideal solution.
|
# ? Feb 5, 2014 01:15 |
|
Gnack posted:I'm using Laravel for a project I'm working on and I'd like to start using LESS to make CSS a little easier to maintain. I'm wondering if anyone has some pointers on decent asset managers for Laravel that will take care of auto-compiling the LESS for me? Preferably I'd like it to autocompile the LESS to CSS whenever it picks up that the LESS file has changed. I stumbled upon this over the weekend. It sounds like what you're describing. http://mun.ee/
|
# ? Feb 5, 2014 01:23 |
|
Depressing Box posted:I haven't found a good asset manager for Laravel yet, but I've gotten pretty good results setting up a watcher and some build tasks with Gulp (formerly with Grunt, but I find Gulp a lot easier to work with). Here's a quick overview, and a more in-depth video tutorial. I don't mind if it's slow-ish, as it will only be used in development. But I've started using LessPHP and I'm having trouble already at the starting line. I have this in my less file: code:
|
# ? Feb 5, 2014 03:34 |
|
You might want to look into using Foundation with Sass and Compass. I know you wanted LESS, but Sass is hard to beat (Bootstrap was also just released with Sass support as well giving some people the idea that Sass "won").
|
# ? Feb 5, 2014 04:08 |
|
musclecoder posted:You might want to look into using Foundation with Sass and Compass. I know you wanted LESS, but Sass is hard to beat (Bootstrap was also just released with Sass support as well giving some people the idea that Sass "won"). To be honest I'm only just starting to delve into LESS/SASS and this is a brand new personal project so I don't have a preference for either here. I'll give SASS a try - thanks!
|
# ? Feb 5, 2014 04:44 |
|
substitute posted:I stumbled upon this over the weekend. It sounds like what you're describing. This. Supports compiling LessCSS, SCSS (Sass), condensing files to one request, minifying javascript and basic image manipulation (and I know the guy who made it). You can install Munee really easily with composer or just download it, and one php file and .htaccess rule later, you'll have it handling all your assets. Seriously worth checking out.
|
# ? Feb 5, 2014 10:12 |
|
God, you kids and your repositories and composers and frameworks. In my day, everything was done by scratch, and if you dared using anything close to even resembling a library, your paranoid boss would be afraid he'd be accused of stealing code.
|
# ? Feb 5, 2014 17:52 |
|
Nebulon Gate posted:God, you kids and your repositories and composers and frameworks. In my day, everything was done by scratch, and if you dared using anything close to even resembling a library, your paranoid boss would be afraid he'd be accused of stealing code. Oh man I'm still partially at this stage at work because of various factors and it sucks (not the "stealing code" thing). I so wish I could scrap several aspects in our setup and workflow, and use actual tested and well maintained PHP frameworks for projects. I constantly say I reinvent the wheel for a living, but some days/weeks, it's feels like I'm reinventing the hammer and chisel. substitute fucked around with this message at 18:20 on Feb 5, 2014 |
# ? Feb 5, 2014 18:17 |
|
Nebulon Gate posted:God, you kids and your repositories and composers and frameworks. In my day, everything was done by scratch, and if you dared using anything close to even resembling a library, your paranoid boss would be afraid he'd be accused of stealing code. Yeah I'm in a real period of adjustment at the moment where I'm trying to catch up with some pretty serious shifts in the way web development works these days. All these libraries and utilities that used to be unnecessary but now have very genuine usefulness, and somehow I missed it all so now I'm catching up. I thought Composer would come and go, I thought Node.js would come and go, I thought SASS and LESS would always remain just kind of a niche thing. I suck at predicting the web is what I'm saying.
|
# ? Feb 6, 2014 06:13 |
Gnack posted:I suck at predicting the web is what I'm saying. Today's your lucky day, friend. I'm putting together a team of enthusiasts to develop an online player-controlled graphical video computer console game. It's this fantastic new thing called an Em Em Oh and it's the closest thing you'll get to legally printing your own money. It's on the cutting edge of computer technology and it will transform the way children and the mentally deranged spend their time. Rather than creating a software video game and selling it only once to each child, we sell them the software and they then pay us to continue using it. Now, you may be asking -- what money does a child have to pay for console video playables? They don't let children work anymore! But today's new urban parents are paying more and more money to distract their chubby children, and if we act now, the right product could completely monopolise this emerging market and secure a virtually limitless income -- for ever. Please send all inquiries via pneumatic tube.
|
|
# ? Feb 6, 2014 10:01 |
|
That site does a horrible job of explaining what Foundation is to someone who does not already know what Foundation is. Apparently it's some kind of a framework, but then again, everything is these days.
|
# ? Feb 6, 2014 19:28 |
|
What the gently caress? There's a foundation 5 now?
|
# ? Feb 7, 2014 00:07 |
|
How do adults parse XML in PHP in the year 2014? I don't really have much experience in XML parsing in general, but recently I have done it in Java and C# semiautomatically by generating a class structure from schema. It was a surprisingly pleasant experience. Nothing similar for PHP immediately jumped forward when I googled for it, except for one apparently unfinished project. Well, now I'm going to have to interface with a web service that both inputs and outputs XML. So I need something to generate valid XML for making requests and I need to parse the response to get the data I requested. Looking at SimpleXML, that looks painless enough for generating simple requests. I might be able to live with that. But processing incoming XML with, say DOM, sounds potentially lovely. I can probably live with that as well if need be, but if there are better options, I'd like to hear about them at least. late edit: Looks like I misunderstood SimpleXML's purpose. I thought it was meant for encoding data into XML, but looks like it also parses XML. Well, I'm going to try that for now and see if I run into some massive problems. Wheany fucked around with this message at 15:35 on Feb 7, 2014 |
# ? Feb 7, 2014 14:04 |
|
Wheany posted:
Guzzle can output SimpleXML and probably you could extend guzzle to use DOM. If you need to validate with a schema than I think DOMDocument works better.
|
# ? Feb 7, 2014 18:24 |
|
It also depends on the size and complexity of the document. SimpleXML gets funky when the XML has, oh, I dunno, attributes. And gods help you if there are namespaces! While the XML parser functions will do a fine enough job, they're kind of annoying to deal with. Also, take every bit of code in the comments on the xml_parse page with a tablespoon of salt. Yikes. There's also XMLReader, which is a pull parser, designed for large document reading without huge memory use.
|
# ? Feb 7, 2014 19:10 |
I don't know if its because im sick as a dog and my eyeballs feel bruised or if im missing something obvious but i feel like an idiot, i cant get simplexml to output the text string it would dump into the xml file. As in, i need to save a copy as an xml and a copy in the database and strip the xml tag (i.e. Versioning and document declaration) as well. No matter how i manipulate it, or output and try to re read the file line by line (not using simplexml), it only ever gets the values of the content. What am i missing? I know its not a common need and i probably don't need to strip the declaration but why am i having such a hard time transforming an xml document or simplexml object into a simple string?
|
|
# ? Feb 7, 2014 22:13 |
|
asXML() ? Edit: If you wanted to go the other direction, I'm pretty sure you can cast the SimpleXML object to a string. revmoo fucked around with this message at 00:08 on Feb 8, 2014 |
# ? Feb 7, 2014 22:21 |
|
I'm looking for a little help with regex, I'm working on fun little script that is parsing my video files and pulling down information from a movie database. To make it easy to determine an accurate name based on the filename, I have some regex that works great from the command line but not so great with preg_match or preg_replace... I'm trying to insert a space before all capital letters and the first number in a sequence. Look at the example below. echo 'ChroniclesOfRiddick or LethalWeapon3 or Dracula2000' | sed 's/\(\S\)\([A-Z0-9][0-9]*\)/\1 \2/g' Chronicles Of Riddick or Lethal Weapon 3 or Dracula 2000 How can I do this in PHP? I figured out how to split on capital letters, but I can't get the numbers to work as well. $new_title = preg_replace('/(?<!^)([A-Z])/', ' \\1', $title);
|
# ? Feb 7, 2014 23:29 |
|
mooky posted:I'm looking for a little help with regex, I'm working on fun little script that is parsing my video files and pulling down information from a movie database. To make it easy to determine an accurate name based on the filename, I have some regex that works great from the command line but not so great with preg_match or preg_replace... This seems to get the job done: $new_title = preg_replace('#(?<!^|\s)([A-Z]|\d+)#', ' $1', $title); Those "#" are used as delimiters. You can pick any character you want, so I usually opt for them rather than "/", so there's not as much escaping needed.
|
# ? Feb 8, 2014 04:09 |
revmoo posted:asXML() ? asXML was also outputting just the content but now I can't remember if I did the obvious thing and escaped all the characters etc.. The browser might have just been parsing it as part of the HTML elements.
|
|
# ? Feb 8, 2014 10:09 |
|
obstipator posted:This seems to get the job done: Hey thanks, that works great. I do have a problem if the file name already contains spaces. Is there an easy way to work around this? In a perfect world I would just rename everything...
|
# ? Feb 8, 2014 21:39 |
e: disregard
Sulla Faex fucked around with this message at 00:29 on Feb 9, 2014 |
|
# ? Feb 9, 2014 00:02 |
|
mooky posted:Hey thanks, that works great. I do have a problem if the file name already contains spaces. Is there an easy way to work around this? In a perfect world I would just rename everything...
|
# ? Feb 9, 2014 04:18 |
|
What's the proper way to filter content with html entities in it into something RSS xml compliant? I tried a bunch of things last night and nothing seemed to convert them or filter them out right. E: nm ENT_XML1 worked well. revmoo fucked around with this message at 17:59 on Feb 12, 2014 |
# ? Feb 12, 2014 13:40 |
|
Any good "empty" frameworks to use? Trying to get away from the enormity of CodeIgniter.
|
# ? Feb 13, 2014 18:08 |
|
Vintersorg posted:Any good "empty" frameworks to use? Trying to get away from the enormity of CodeIgniter. If you're looking for truly empty... https://github.com/phillipsdata/minphp It's what the billing software Blesta is built from. It looks good if you want nothing to start with. The documentation is lacking and it isn't great on the inline comments, but you can download the blesta trial and look at most of the source code to get an idea of how it all ties together. I decided on this for a very small project that just needed basic MVC functionality with a PDO wrapper.
|
# ? Feb 13, 2014 18:17 |
|
Vintersorg posted:Any good "empty" frameworks to use? Trying to get away from the enormity of CodeIgniter. Here's one I found, from looking at the guy's PHP-login project. I haven't used this framework, but it looks pretty simple and lightweight. http://www.php-mvc.net/
|
# ? Feb 13, 2014 18:27 |
|
I would avoid anything that doesn't use Composer. There's Slim and Silex for doing basic sites. What's your use case though? Sometimes the "big" frameworks are the right tool.
|
# ? Feb 13, 2014 19:30 |
|
EDIT: Nevermind, figured it out. That's a rare one for me.
Lareous fucked around with this message at 20:46 on Feb 17, 2014 |
# ? Feb 17, 2014 20:24 |
|
Lareous posted:EDIT: Nevermind, figured it out. That's a rare one for me. Why the hell do people keep doing this? Just put the answer in the next post.
|
# ? Feb 18, 2014 14:38 |
Probably just a non-erroring typo or something similar. It doesn't help anybody else because it's a project-specific fuckup and by leaving the original post it can skew future searches that hit on the keywords. That's why I removed mine half a page up, I had a problem with something or other that just boiled down to a misnamed folder caused by reading the wrong lovely tutorial.
|
|
# ? Feb 18, 2014 14:51 |
|
I'm doing a web site for some friends of mine and most of the important data will be stored in an SQL database. I set up a password-protected page so they could enter data in the DB and send files to the server and I'm wondering how secure it has to be and if the authentication scheme I used is a horror; bear in mind this is the first time I try such a thing. So the way I did it is they have to go to a "not public" page (i.e. no link to it from the front site) , input a username and password which are sent as POST to the target page. If the (sanitized) passwords match it echos the form to add data to the server, otherwise it echos nothing. It feels secure to me as first you have to know the login page even exists, second even though the login information is in the php files, if I turn error reporting off it seems like there'd be no way for an attacker to even know what variable names he has to POST the protected page, much less what values they have to take. Am I underthinking this? I couldve stored the password as hashes in the DB but it didnt really feel necessary cause only 3 people will be using this. Colonel J fucked around with this message at 18:17 on Feb 20, 2014 |
# ? Feb 20, 2014 18:08 |
|
Currently I am using wamp on a windows machine and have kohana up and running for one site. I would like to deploy another site which is completely separate and uses a different copy of kohana. To do so I added file structure and deployed kohana as follows +wamp ++www +++site1 ++++kohana +++site2 ++++kohana Currently my apache httpd.conf listener is as follows Listen 0.0.0.0:80 And my hosts file in the windows directory is set up as 127.0.0.1 localhost 127.0.0.1 site1.localhost 127.0.0.1 site2.localhost Currently when I go to localhost it will go to site1.localhost. Or if i go to site1.localhost it will go to site 1. If I go to site2.localhost the application will redirect to site1.localhost I am very new to PHP/Kohana so this may be a very basic issue, for that I apologize.
|
# ? Feb 20, 2014 19:08 |
|
Set up apache to run vhosts. This way you can redirect a request to a different root folder depending on the domain name. It looks like this in your httpd/conf:code:
Additionally, you don't need to put the sites under the wamp/www folder; you can direct it to anywhere. I've set it up to redirect to another folder for easier access to the code so I don't have to root around every time I want to make a change.
|
# ? Feb 20, 2014 20:18 |
|
|
# ? Jun 7, 2024 18:19 |
|
Ah thanks for your reply. Got it working based on that recomendation
DholmbladRU fucked around with this message at 20:47 on Feb 20, 2014 |
# ? Feb 20, 2014 20:27 |