Jump to content

alexweber15

Members
  • Posts

    238
  • Joined

  • Last visited

Posts posted by alexweber15

  1. I'm all for building it yourself! :)

    I've been in a similar situation in the past, where using a CMS seemed like overkill.

     

    That said, depending on your experience, some frameworks might be a bit intimidating at first (took me a while to get used to Zend Framework for example).  Cake looks nice and I've been wanting to try it, I say go ahead and try some of the available tutorials to see if you feel comfortable with it.

     

    One thing you want to keep in mind when building it yourself is planning... try to figure out exactly what you need and how it will come together before diving in so you don't end up having to redo something or even worse create kludges that will bite you in the ass down the road!

     

    On the other hand, with a CMS you can be really experimental and reorganize things a lot along the way. :)

  2. This function can modify and check the file extensions that the built in __autoload() fallback function spl_autoload() will be using.

     

    If you make your own autoloading function, there will not be used any fallback.

     

    So basically if I have no autoloader expilcitly defined but I define spl_autoload_extensions() then the fallback will look in my include_path for corresponding files with the defined extensions?

  3. I'm trying to figure out what's the point of this function!!

     

    I registered the extensions I'm using ('.class.php,.php') and correctly set up my include path but the I get warnings saying that "path/to/file" can't be found.  (even though the class is located in path/to/file.class.php) I also use some 3rd party components that are named "file.php" so I've got to account for both.

     

    Now, I've figured it out and my autoloader works fine, but I'm really just wondering what's the point of spl_autoload_extensions if I have to manually specify the extensions myself??  The more intuitive approach would be that you could leave out the extensions and it would automatically search for both types right?

  4. Hey DjKat thanks for the feedback!

     

    I totally agree with you and personally I don't use Smarty at all but, at the end of the day, I don't have much of a choice in this department!

     

    The rest of the developers on the team are very enthusiastic about it and all the templates are ready to begin with!  So really whether I like it or not we're using it!

     

    I'll read up on Zend_Layout and hopefully it will point me in the right direction!

  5. We're in the process of rewriting our biggest app MVC-style.

     

    The code is a complete mess but the one solid thing is the templating done with Smarty, so we want to stick with it.

     

    I don't really have any Smarty experience and I'm not sure how to properly implement it in the MVC context; what's better?

     

    - Instantiate the class every time its needed (ie the controllers)?

    - Instantiate the class once during the bootstrap process and pass it as a parameter to the controllers?

     

    (right now its a global variable, which afaik isn't ideal)

     

    thanks!

  6. Thanks for the reply Garethp, that's pretty much what I'm doing.

     

    And to avoid out of bounds errors:

     

    if(isset($array[$index])){

        // compare

    }else{

        // reached a boundary

    }

     

    I was hoping someone out there already had this problem and created an awesome class so I wouldn't have to do it myself! :)

  7. Hi,

     

    I'm working on a project with data that is represented as a n*n matrix.

     

    Its easy enough to do this using a multidimensional array but the catch is that I need to be able to check adjacent squares and other grid-like functionality.

     

    Again, I've managed to bypass this using arrays but its kind of annoying.

     

    So I ask:

     

    Is there some kind of grid data structure that anyone can recommend?  With native implementation of stuff like checking squares above, below, etc?

     

    Thanks!

  8. I've beta testing a website using htpasswd to protect the directory but I rely on 3rd party tools to generate user & password combinations and I don't like that.

     

    Some places say it's md5, others crypt() and others say its a specific apache md5 version but at the end of the day I haven't been able to emulate it...

     

    Can anyone shed some light please so that I can generate my own username & password combinations without relying on a third-party website?

     

    Thanks!

     

    Alex

  9. thanks for the replies and that's kind of what I was expecting to hear! :)

     

    I've read up on Smarty in the past and done a few small things but there was always a lot of business logic going on specially when passing objects to the view...

  10. There's not a hell of allot of libraries around for you to be able to do much useful stuff with php on the desktop, you'd probably be better going with something like Python (for ease of use) or C++ / C# if you wanted to get serious.

     

    how would databases work without a web-server involved?

     

    I don't see how databases relate to web servers. Database servers or even simple database engines like sqlite in no way depend on a http server being present.

     

    what I mean for mysql for example it would require the client to have a local mysql server, which isn't that common outside of the developer world so unless you use a flatfile or sqlite which can be bundled easily it would be a problem afaik

  11. Here's how I see it:

     

    Use a Singleton if you want to have at maximum 1 instance of the class at any given moment.

     

    If your Singleton's constructor is empty then you really don't need the class to be instantiated at all, in which case you would use a static class (just remove the getInstance method)

     

    Abstract classes are a whole different thing.  You would use an Abstract class if your class is part of a class hierarchy and you have an abstract parent and concrete children that have similar properties and methods but may also have different implementations of a certain method.

     

    If there is no defined hierarchy then you should use interfaces instead.

     

    Hope I helped instead of confusing more!

     

    Alex

  12. I noticed Smarty hadn't received an update in a few months dating back to last year (up until recently) and with a lot of talk I've been hearing recently about PHP as its own templating language being the best option I turn to you guys:

     

    Is Smarty still a good choice and in what cases?

     

    For example: How well does Smarty + MVC Framework (Zend, Yii, etc) perform?

     

    I realize that Smarty is probably the best templating engine for PHP out there but I've become slightly discouraged recently... how many of you actually use it on a regular basis?

     

    Thanks!

     

    Alex

  13. I've been using the Kohana framework, and also CodeIgniter framework.

     

    I have my forms post back to the same controller that produced them, run some validation if the post token = session token, and if all is well I use cURL to post to a processing script that returns a confirmation or error message, which is then pushed into the view.

     

    If there were errors in validation, the cURL post is not done, and errors messages are pushed into the view, and the form is prefilled with the data that passed validation.

     

    If the post token != session token, the user simply gets the standard view, sans any prefilled form data.

     

    I could send you my contact controller file if you want to see, but I don't want to post it here.

     

     

    Thanks for the reply!

     

    Yeah I'm curious to see it if you wouldn't mind sharing...

     

    Alex

  14. thanks for the reply, gotcha, that's what I've been doing it but I just always figured there was a better way to do it... guess not! :)

     

    Since I seem to have your attention mind taking a look at my original question about submitting forms?

     

    In a nutshell: When programming with classes I usually end up having a handful of classes and the regular PHP/HTML pages that take care of user interactions and I always end up creating a file called 'submit.php' that's a central place to direct all form submissions, route them to the appropriate classes/objects and then return flow back to the user (which is where I would output JSON in the case of AJAX stuff)

     

    I never liked the whole 'submit.php' thing but can't think of a better way to do it... is there any?

     

    thanks

     

    Alex

  15. sorry i meant conVention!! :)

     

    and yeah I know, I do use json_encode() but then I end up doing a die() with the encoded values in order to send them back to my javascript and that just doesn't seem that elegant but maybe its the way.

     

    I figured doing something like Header('Content-type: application/json') would be more approriate but it doesn't seem to work.

     

    Alex

  16. sup all, lately I've been to use OOP in my PHP work and it's definitely made my code more reusable and elegant but there's one thing that I still do the same as before and it kinda bugs me... submitting forms.

     

    I always end up having a file called "submit.php" that collects POST data and redirects the script flow to the correct class/method combination.

     

    And when I use AJAX, all the file does is:

    die($_SESSION['myObj']->myMethod($_POST[...]);

    (the functions all return JSON objects)

     

    All this doesn't seem too OOP and elegant at all to me.

     

    What's the convention for handling form submits with OOP?

     

    And also is there a more elegant way to return JSON objects ?  (can you do like content-type="text/json"?")

     

    thanks

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.