Jump to content
MakeWebGames

EasyPHP Class


Script47

Recommended Posts

What is the licence to use this?

Also another function that would be handy would be to change the content type of a file something like:

    /**
    * Changes the content type of the requested web page.
    * @param $contentType - The content type of the page.
    */
   public static function contentType($contentType) {
       switch($contentType) {
           case "csv":
               $fileType = "text/csv";
               break;
           case "xml":
               $fileType = "application/xml";
               break;
           case "json":
               $fileType = "application/json";
               break;
           case "stream":
               $fileType = "application/octet-stream";
               break;
       }
       header("Content-type:".$fileType.";");
   }

The above is untested, you could also make a function to convert an array to a data type i.e. json, xml or csv.

We have done this for our project at work for the API we are building

Edited by Dayo
Link to comment
Share on other sites

[MENTION=65371]sniko[/MENTION], thanks for all the messages on GIT, I'm looking in to them now.

 

Nice!

I'm looking to make a tribal wars style game, Might use this class :O

thanks!

No problem! I'm going to be updating it as much as I can so feel free to give me any feedback.

 

What is the licence to use this?

Also another function that would be handy would be to change the content type of a file something like:

 

    /**
    * Changes the content type of the requested web page.
    * @param $contentType - The content type of the page.
    */
   public static function contentType($contentType) {
       switch($contentType) {
           case "csv":
               $fileType = "text/csv";
               break;
           case "xml":
               $fileType = "application/xml";
               break;
           case "json":
               $fileType = "application/json";
               break;
           case "stream":
               $fileType = "application/octet-stream";
               break;
       }
       header("Content-type:".$fileType.";");
   }

 

The above is untested, you could also make a function to convert an array to a data type i.e. json, xml or csv.

We have done this for our project at work for the API we are building

In terms of the license, do what you want with it but don't claim it as your own and don't remove the comment block at the start of the class.

Thanks for the idea pal, will look in to it.

Link to comment
Share on other sites

Looks great! Would scrap the use of the <font /> tag, that's some legacy stuff! http://www.htmlgoodies.com/tutorials/html_401/html4-ref/article.php/3460291

Also the $_SERVER['HTTP_X_FORWARDED_FOR'] can be faked very easily and was an original issue in McCodes v2.

and within your isEmpty function surely $variable is always set?

public static function isEmpty($variable) {        
   return !isset($variable) || empty($variable) ? FALSE : $variable;    
}
Link to comment
Share on other sites

Looks great! Would scrap the use of the <font /> tag, that's some legacy stuff! http://www.htmlgoodies.com/tutorials/html_401/html4-ref/article.php/3460291

Also the $_SERVER['HTTP_X_FORWARDED_FOR'] can be faked very easily and was an original issue in McCodes v2.

and within your isEmpty function surely $variable is always set?

public static function isEmpty($variable) {        
   return !isset($variable) || empty($variable) ? FALSE : $variable;    
}

Haha, yeah the font stuff is just very easy. xD But mainly it was used to make point of how the function works and how you can display difference messages.

I removed the HTTP_X_FORWARDED_FOR after a chat with [MENTION=65371]sniko[/MENTION] main class will be updated tonight.

That function works fine, it is what I use for forms in HTML, so you can use this function to check if a form field is empty, and I've tested and it works fine. Also that function will be changed a little bit in the update tonight.

Thanks for the feedback pal.

Link to comment
Share on other sites

In terms of the license, do what you want with it but don't claim it as your own and don't remove the comment block at the start of the class.

So could i use this for commercial use where the customer will never see the code?

(well i couldn't at them moment as there is no licence)

Link to comment
Share on other sites

  • 2 months later...

EasyPHP Framework

 

So I've been working on this a bit more and these are the ideas/how it will work. This is currently available on GIT but as only one class with a bunch of functions which have just been garbled and put in to a file. Whereas now I have this sort of structure and several files which will be used to break down processes.

So lets say you have a random project, a simple To-Do List. The file structure might be like this.

To-Do List

 

-css

 

-js

-php files?

With EasyPHP it would be like this. The crucial difference would be that there is a EasyPHP folder with a structure like the following.

To-Do List

 

-EasyPHP

 

-library

 

-logs

 

-errors.txt

 

-Authentication.php

 

-EasyPHP.php

 

-ErrorHandler.php

 

-Sanitize.php

 

-Session.php

I plan on making classes for both PDO and MySQLi, we'll see how that goes. I have already made the PDO one with chainable queries, but might change a few bits and bobs on that.

Inside library folder will be your application specific PHP classes, they will be autoloaded. That is the current idea. Tomorrow I would go in to more details about the classes hopefully. Any classes or ideas you'd like to see, just post below. I'll see if they can be added.

Link to comment
Share on other sites

EasyPHP Framework

I plan on making classes for both PDO and MySQLi, we'll see how that goes. I have already made the PDO one with chainable queries, but might change a few bits and bobs on that.

Inside library folder will be your application specific PHP classes, they will be autoloaded. That is the current idea. Tomorrow I would go in to more details about the classes hopefully. Any classes or ideas you'd like to see, just post below. I'll see if they can be added.

 

They would be called singelton classes..

But, something I usually overlook is a File/Image class. I actually included one of these in my latest project I am working on.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...