oh nice php



So I could either do

Code:
echo 'hello world' ;

with php or I could do



Code:
//With default settings
Slim::init();

//With custom settings
Slim::init(array(
'log.enable' => true,
'log.path' => './logs',
'log.level' => 4,
'view' => 'MyCustomViewClassName'
));

//GET route
Slim::get('/hello/:name', function ($name) {
echo "Hello, $name";
});

//POST route
Slim::post('/person', function () {
//Create new Person entitiy
});

//PUT route
Slim::put('/person/:name', function ($name) {
//Update Person entity with given name
});

//DELETE route
Slim::delete('/person/:name', function ($name) {
//Delete Person entity with given name
});

Slim::run();

with slim.


hmmmmmmmmmmmmm
 
lol

The advantage to something like this is you can write an API and have all routes/calls in a single file, whereas with standard PHP you're going to have different files for each function/request type. Makes managing small APIs nice.

You are also able to extract the Business (controller) logic from the rest of the code, like your views and models. Makes it much easier to build big systems because of the inherent code organization of MVC
 
Seems like a good place to ask this question:

I've been learning n00b php and have a few basics down. -No bragging rights yet.

But whenever I pick up a book on php, it always goes into directions I'm not interested in...

I don't need (yet) mysql interfacing nor most of the higher-level coding that I always see you guys talking about when you start php threads around here; but I do need to learn more, specifically about how to target visitors by keyword, IP (geo), or otherwise and present the page to them I want each time... Such as the most relevant ads.

I'd be doing this in a Wordpress & linux (hostgator shared) environment. Anyone here know the best place to learn more php, specifically down that path?

& Does Slim Micro offer any advantage for this purpose?

Thanks!
Luke
 
@lukep:

php allows you to write both object oriented code and simple programs, what you're looking for is simple code that doesn't require classes, maybe nor methods.

I have never bought a PHP book and I think that, for simple things like what you mentioned, searching for them on google will be enough.
But don't limit to copy/paste the solution: try to understand what happens and how it is done in PHP.
 
...specifically about how to target visitors by keyword, IP (geo), or otherwise and present the page to them I want each time... Such as the most relevant ads.

I'd be doing this in a Wordpress & linux (hostgator shared) environment. Anyone here know the best place to learn more php, specifically down that path?

Not criticizing you here, mate, but Google is your friend.

Googled: "php visitor keywords"
How to know what keywords visitors Googled to reach your site? - Dynamic Guru

Googled: "php geolocation"
geoPlugin's free and easy PHP geolocation webservice explained

The later I have used on many sites.

What you'd do is have a database (yup, you're gonna have to pull out those books you have been avoiding) that has a keyword that you group certain ads with, then when a visitor visits a page, have their keyword phrase use the "LIKE" parameter in the where clause to match up with the keyword groups in the database and choose an ad from there.

You could do similar with the IP if you only want to show ads by region.

Ideally you'd have a pretty database model with one table for potential keyword groups, another for potential regions, and then reference the id for the IP or keyword group in the ads table. This is called normalization since you aren't repeating data in multiple places.
 
It's encouraging to hear that G is all I need, thanks guys.

I used KWs in the past to search (breifly) before like like "Php tutorials" but couldn't think of what terms exactly I'd need to search for to find info on dynamically targeting pages... Never would have thought of "php visitor keywords" so thanks Rex!

-As for geolocation, I've used maxmind's paid db in the past for some wordpress plugins and switched to their free DB version last week when they basically raised their prices by 50,000%. Assholes. At least the free db is targeting well now and I can use a Bot to update my version of it across all my hosts each month. (It's a monthly dat file, no sql.)

So I'll try some more searches for "php" & "dynamic" terms, just need to know how to fit it all together now.

Cheers,
Luke
 
Oh what do you know, over zealous coders trying to come up with a wacky solution because they can't write their own code. Shocking! (not really)

The advantage to something like this is you can write an API and have all routes/calls in a single file, whereas with standard PHP you're going to have different files for each function/request type [allegedly]. Makes managing small APIs nice.

You have to be kidding me man, it's really not that hard to write your own API, especially if it's small. You guys make me wet my pants from laughing too hard.

You are also able to extract the Business (controller) logic from the rest of the code, like your views and models. Makes it much easier to build big systems because of the inherent code organization of MVC

Again, L-OH-Fucking-EL man. You just keep trucking with that MVC bullshit. Anyone that drinks this cool-aid can never be very good outside a corporate environment where there is a large array of retards writing code (lets face it there is a huge variety of coders from the tadpoles to the sharks). I applaud the effort though.

I honestly try to understand, but the more code I write the more I realize that the whole OO and Framework movements are meant for retards/lazy coders/those who can't write it themselfs. I don't like to say that about anyone, really. However if you can't see how crazy this all is you'll never ascend to the heights you can. If you need a framework to write your own API I have no idea what to say besides, good job wasting your time. In the time it took to learn it, you probably could have wrote your own if you where any good.

I'm not trying to start a coding mythology war, I'm really not, and please don't take it like that. We've been through this a million times it seems. Lots of people get taught frameworks and OO programming because they are "standards" and they lean of them badly that's all I'm saying (or that's my thought at least).

I'd be doing this in a Wordpress & linux (hostgator shared) environment. Anyone here know the best place to learn more php, specifically down that path?
Well true it may be a Linux environment but you have no real control over it, so that point is moot. There are a lot of threads discussing where and how to learn PHP or other languages. Read them, take away what you can (because we fight like a bunch of nerds duh!) and continue. It's a journey that's for sure.
 
  • Like
Reactions: -God-
@Rage9: I agree that its not that hard writing your own API, but its always good to us something that's already made and works, if it's good ofcourse... But I dont think frameworks and OO programming is for lazy coders, it depends on what you need! No need for a framework for a blog maybe, but for a bigger commercial website, why not ?
 
I would recommend to use CakePHP as a framework. CodeIgniter is very overloaded and too complex imho, if you want something like that better use Kohana which was forked from CodeIgniter.
 
Oh what do you know, over zealous coders trying to come up with a wacky solution because they can't write their own code. Shocking! (not really)



You have to be kidding me man, it's really not that hard to write your own API, especially if it's small. You guys make me wet my pants from laughing too hard.



Again, L-OH-Fucking-EL man. You just keep trucking with that MVC bullshit. Anyone that drinks this cool-aid can never be very good outside a corporate environment where there is a large array of retards writing code (lets face it there is a huge variety of coders from the tadpoles to the sharks). I applaud the effort though.

I honestly try to understand, but the more code I write the more I realize that the whole OO and Framework movements are meant for retards/lazy coders/those who can't write it themselfs. I don't like to say that about anyone, really. However if you can't see how crazy this all is you'll never ascend to the heights you can. If you need a framework to write your own API I have no idea what to say besides, good job wasting your time. In the time it took to learn it, you probably could have wrote your own if you where any good.

I'm not trying to start a coding mythology war, I'm really not, and please don't take it like that. We've been through this a million times it seems. Lots of people get taught frameworks and OO programming because they are "standards" and they lean of them badly that's all I'm saying (or that's my thought at least).


Well true it may be a Linux environment but you have no real control over it, so that point is moot. There are a lot of threads discussing where and how to learn PHP or other languages. Read them, take away what you can (because we fight like a bunch of nerds duh!) and continue. It's a journey that's for sure.

I code to build functional tools to make money from, not to fap over my fantastic reinventions of the wheel each time :)

Frameworks & MVC are the natural progression of programming techniques. It standardizes the code structure of large applications allowing teams to easily collaborate and allows easy maintenance months down the road. I haven't coded regularly on Layered Links in over 6 months, but any time I need to jump in to add a new feature I can find the place to do so in just a few seconds.

You're right though, frameworks are for lazy people. Lazy people don't like to do a whole bunch of extra work to get something done every time they work on a project. So they use boilerplate code to finish shit fast so they can get back to being lazy.

Are you comin to SD next month or what bro? I <3 our programming-method-hating/packers-loving friendship
 
... the more code I write the more I realize that the whole OO and Framework movements are meant for retards/lazy coders/those who can't write it themselves.

Frameworks are perfect for people who have just started. They get to benefit from the experience of the cloud.

For those of us who've gone through the school of hard knocks, our reusable assets (existing code) and experience is what makes us a superior choice for any hack ... but a terrible choice for corporate USA.

You're ALWAYS going to be more intimate with code you've written from scratch. It's going to be a better tool to use every time.

... fap over my fantastic reinventions of the wheel each time :)

Frameworks & MVC are the natural progression of programming techniques. It standardizes the code structure of large applications

I had to make my own wheels before they were sold in stores. I own the wheel factory and now I can make as many wheels as I want without having someone giving me the instruction manual.

A natural progression for experienced programmers is to create your own code base. Other stuff should be picked up for fun, not productiveness.
 
Last edited:
I would recommend to use CakePHP as a framework. CodeIgniter is very overloaded and too complex imho, if you want something like that better use Kohana which was forked from CodeIgniter.

Kohanas direction as a project is completely disjointed and chaotic to say the least. I use to be a fan of Kohana until version 3 where they basically said "Hey guys welcome to this completely new framework, but don't worry we're still calling Kohana."
 
I would recommend to use CakePHP as a framework. CodeIgniter is very overloaded and too complex imho, if you want something like that better use Kohana which was forked from CodeIgniter.

I think you have that backwards? most people agree cake is too fat and codeigniter is the nice lean framework.
 
Whatever gets the job done faster - as long as it performs as expected, and is maintainable. CakePHP, Symfony, Zend, CodeIgniter, Kohana, Rage9's special, erect's wheel factory...it doesn't matter much which one you choose, as long as you are comfortable with it.

Just make sure that the framework which you are choosing is actively developed. Slim seems to be maintained by a single person.