PHP based image management - php

A reason I've picked up working with the Zend Framework was that I keep hearing how easy it is to reuse code and not have to reinvent the wheel every time you start a new project.
I do find this true for my own code, but find it pretty hard to find quality external sources that can integrate well into the system.
Anyway, I'm basically looking for pre written PHP code (preferably supported by frontend js scripts) that s flexible and wraps the most common tasks relating to image management. (cropping scaling, validation of mimetypes/sizes/dimensions etc) into a useful/flexible class.
Any recommendations?
Thanks

Anyway, I'm basically looking for pre written PHP code (preferably supported by frontend js scripts) that s flexible and wraps the most common tasks relating to image management.
I'm not sure you're going to find a complete general-purpose drop-it-in component for this, but you can stitch something together without a problem.
jcrop is a jQuery plugin to handle the client-side bits of image cropping.
Imagine is a new PHP image handler, wrapping either GD or the Imagick/Gmagick extensions. It has a powerful, convenient, fluent interface with comprehensive cropping, thumbnailing and resizing support.
As for gluing them together, that'll be up to you... but given that these two libraries can handle most of the work, it should just be some quick bits and pieces in your controller code.

You might want to check Nette Image. It has far the best interface I've seen ;)

It's true that code reuse isn't very complicated, but making pieces of code from all over the place work TOGETHER can be very complicated. Have you looked into using a more general purpose framework like CakePHP?
Have a look here: https://stackoverflow.com/questions/2648/what-php-framework-would-you-choose-for-a-new-application-and-why

Related

PHP5 PDF Generation?

So lately I've been thinking of building and implementing my own invoice system with PHP and I want to have an optional 'Download/Generate PDF' button that creates a PDF based off of either a template that was created or based off of html/css.
I want a method that is free (seeing as some are ridiculously overpriced) and hopefully not too difficult to use. The end goal is to create something that would be good enough for commercial use (though it's not my intent to sell it).
I've heard of options such as TCPDF, Dompdf, wkhtmlpdf etc. But again I'm looking for one that would render most correct, and potentially be used commercially. I'd like suggestions specifically based off of what I require as I have searched the site for topics that are similar; I'm aware of the different libraries but not sure what I should use.
Thanks in advance! :)
Having done this a couple times, my suggestion would be to take an existing library that wraps up the low level PDF tools into a decent API, and then build your own library that is specific to your needs (invoicing) on top of it.
I would suggest Zend PDF or TCPDF as a base library to build on. As you add classes to your own library you'll be able to wrap up things like table / line-item generation, headers, footers, etc.
I used FPDF library, I liked it. http://www.fpdf.org/
and check this manual anyway: http://php.net/manual/en/book.pdf.php
I'm often suspicious about low-level reporting systems (TCPDF et al) - they're very well done, but if a business needs a new report, it can take ages to write code to draw the report to client requirements. I therefore prefer GUI/server solutions, such as iReport (used to design a report) and Jasper (reporting server) - the editability of such a report is near-instantaneous, and thus much more responsive to changing business requirements.
On the plus side, it's free and open source, and on the negative side, you'll need a spare server to run it on. It's Java based, but reports can be run via PHP using SOAP.
If you can use external tools, I recommend wkhtmlpdf. It is really simple to use.
Check out the "Integration With PHP" on their wiki: https://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp

How do you convert an old OOP PHP project into the Yii Framework?

I already have a working OOP website. Most of the php is separated from the html. I was wondering if anyone had any tips on how to apply that site into the Yii Framework.
Edit
The website uses jquery, html, css, php, javascript. It also consists of a lot of libraries and classes I bought of code canyon. Like a geolocation library, phpthumb (image thumbnails), like and dislike system. How does one go about importing these libraries into Yii?
I had a similar task a year ago, but the code wasn't really OO at all. I created a new Yii project and placed the old site as a lib in the that project. I then set up the basics in Yii like database access, whichever session values were needed in both projects etc. I then ported route by route, feature by feature. It took some time, but it worked out really well. I just had a bootstrap script which routed requests based on "ported_routes".
When it comes to reusing classes that should not be a problem if they are well structured without dependencies on the old code. Yii places no restrictions on that stuff, so just add them as libs or browse through the Yii docs and see if it makes sense to refactor them into Yii components or subclass something in there.
As for CSS and JS that was redone from skratch, using LESS and newer JS libs. A lot had happened in the JS world since the original code was written. Yii does not require you to follow any predetermined structure for markup either, so in theory you should be able to use the old CSS unless you want to change markup fundamentals.
If your old code has a MVC-like structure the porting of actions and views will go smoother, but regardless you are pretty much left with a similar approach I think.
well there is no hard and fast convertor which will convert your site from traditional OOP model to Yii. You have to do all of it yourself. But you can opt to do it in stages though.
-at mathew commented I must clarify that you have to do it all by yourself and there is no easy way to convert your existing code to what Yii understands

Embedding php and html

Ok, it might be a banal question but i'm a little bit confused.
I'm going to develop a project by my own. This means i'll build the HTML template, the PHP scripts, MYSQL query, AJAX calls and CSS styles.
This means no other people will touch any part of the code.
I know templates are good ways to make the entire application easy to be modified. But is that so necessary to do it? Since i'm the only one who got to know what that files and what that page do?
Using common patterns in the development of software products is not only about making it more readable/maintainable but also about making it extensible. The longer your software will be in use, the more features will be requested/desired. Extending one big mess of a software will not work out in this case.
Try a php framework (e.g. Zend Framework / Symfony(1/2)), there are lots of tutorials which allow you an easy start with or without templating engine (I use twig atm, which does a great job!).
If i were you, i wouldn't use templates (do you mean PHP frameworks?) but thats just me.
You don't have to use a template engine - PHP itself can do that just fine.
In general, it's a good idea to "separate concerns" (eg. code which outputs HTML is separate from code which loads data from the database) - it improves the readability and organization of code, making it easier to maintain and faster to develop further.
You should have a look at a framework, like symfony. Most frameworks make use of MVC and hence provide a good separation of your code.
But is that so necessary to do it? Since i'm the only one who got to know what that files and what that page do?
Yes, if you want to keep it maintainable in the long run. If you are not constantly working on the code, you will forget how some things work eventually and then you are happy if you have a proper separation and organization.

Best high level Web framework, PHP preferred

I'm starting to architect a quite complex web application. The implementation is probably going to be done in PHP, though if there are impressive reasons to choose a different environment I might be convinced.
I've looked at tools like Symfony and CakePHP. The problem is that it feels like they're relatively low level for a modern Web 2.0 application. They handle the basic things like MVC and scaffolding, but not the more advanced UI elements that I'm looking for. Here are some of my requirements:
Single page architecture. With minor exceptions, there should be no page refresh. All actions are done via ajax, the way it's done in gmail, and to a lesser extent in Facebook.
Ajax layout and widget handling. Not only the application doesn't refresh the page, but the developer can specify the layout and load various widgets into different parts of the page. This is somewhat like iGoogle, but should be better integrated.
Support both on the client side and server side for AJAX widgets. It should be trivial to display the result of a select statement in an AJAX table/array like http://developer.yahoo.com/yui/datatable/. This should also apply to other widgets including
Trees
Menus
Forms
Speaking of forms, there should be easy integration with client side validation
Signup/Authentication/Authorization. Including all the housekeeping things like forgot my password, CAPTCHAs, etc.
There's more, but I think I've given enough details so that you get an idea for what I'm looking for. Basically, I'd like to engineer a modern Web 2.0 app and skip writing, testing, debugging things that most web applications need to do. And yes, I know I can take YUI or jQuery and slap it on top of one of the regular platforms, but then I'd have to write all the glue. Now if there are modules that do this, that would be interesting.
So if you say, take Symfony + modules xyz + jQuery and there's your answer, I'd be happy to hear that.
Finally, in terms of priority, I'm looking for something that's scalable, reliable, well engineered more than something that's easy to learn and deploy.
Since you are looking for all things AJAX, why not try GWT? Its not PHP I agree, but it makes writing AJAX applications easy for developers.
I agree with #Iznogood. What your looking for is not actually a framework but a talent.You can make any framework as "igoogle-ish" as possible if you know what your doing.
I suggest look for a framework with a huge and active community like, CI, Cake and Jquery. Search/ask the community for the specific things you need. Plug it in and Presto!
But I'm afraid you'll have to write some of it.
If you don't mind using Java, there is ZK:
http://www.zkoss.org/
I'd prefer using this over GWT.
In php, you might want to consider Cjax http://cjax.sourceforge.net/.
It is MVC oriented, and has a very generic API, with full support for customization, including the development of plugins (There is a full Plugin API available, including documentation, Plugins can be built in PHP and JavaScript in combination -- see uploadify and validate plugins).
It can access all JavaScript functions, Objects and proprieties, and elements properties and functions from PHP server side, with one line of code.
In Cjax,
you can execute ajax actions, inside controllers (ajax requests) - without a line of JavaScript. this allows you to fully function without refreshing the page. It also allows you to access all Js objects from PHP. A good sample that reflects this is the "recursive ajax request" see that demo. The API can be used on page load, when the page first loads, and within every single ajax request.
Do take a look at the documentation and to the 20+ demos included, and no where you will see a single line of JavaScript. It allows you to manipulate elements, containers, request ajax, submit ajax forms, creates overlays, upload files through ajax, all from the server side. Take a glace at the API Table.
It has support for both, server side ajax, and client side, (see plugins JavaScript Documentation)
It plays nice with jQuery - the validation plugin in jquery is full executable in PHP without a line of JavaScript (see http://cjax.sourceforge.net/examples/plugin_validate.php without any custom line of Jquery inside the framework, it's all plugin's work). Ajax Responses from Jquery also get processed by this framework automatically, so using Jquery's Ajax function API wise, is the same as if you were using the Framework's Plugin's JavaScript Ajax Functions.
And you would just have to take your time learning more about it, because it has quite a few more tools that I am sure you'd find useful.
Currently there are two official releases, the generic release and
there is an official release for CodeIgnater of this framework (and it is the leading ajax option for codeignater) , and works great in conjunction other PHP Frameworks and without them.
Signup/Authentication/Authorization. Including all the housekeeping
things like forgot my password, CAPTCHAs, etc.
This is something that you can build within an ajax controller, the framework itself its meant to be a generic "AJAX" framework, so if you are looking for none ajax features, you will need to build them or integrate other PHP Framework with Cjax (such as Codeignater).
I do not know if this matches all of your criteria, or if you ever will find one. However, I like the Zend Framework myself.
As for the UI and AJAX portions - the server side technology matters little, and it's more about browser-side technology and interaction mechanisms, as well as DOM manipulation.
jQuery is my favorite for that. As for the PHP back-end, I tend to develop it with my own codebase that's grown with me over the years.
But all this takes a lot of practice, knowledge, education, research, reading, and posting questions on StackOverflow.com ;)
I would recommend symfony PHP framework since it has very good support for every feature you mentioned, and it can be easily integrated with Zend Framework - as of version 2.0 coming this year it would be integrated in the package. You can easily set symfony to handle AJAX requests so that it would be perfect transparent layer handling server side.
For me, if you look at THAT heavy AJAX, I would recommend searching for some good JavaScript framework - such as Ext.JS - that would handle all client side functionalities.
For the front-end part of your app, you might want to have a look at SproutCore ( http://www.sproutcore.com/ ).
Building a Web application with SproutCore feels more like configuring components than writing code.
There is no glue code.
On the backend all you have to do is accept and emit JSON.
Depends what sort of level you're looking at. If by 'framework' you mean something like Zend or Symphony, then to be honest all the big ones are about as good as each other. They all have strong points and weak points, but none will really meet your criteria.
But your question implies you're looking for something more than that kind of framework. Maybe you're looking for a full-blown CMS platform like Drupal, Joomla or Wordpress?
In that case, again, you need to consider your needs verses the capabilities and pitfalls of each system.
Drupal, for example, has masses of modules, is very powerful, and easy to write your own modules, but isn't object-oriented and doesn't really do MVC, so if that's your bag then you may find it hard to get on with. Wordpress is much easier to get going quickly but is less flexible once you start getting deeper into it.
But again, they all have strengths and weaknesses. If one was clearly the best, it would be an easy choice. But at the end of day perhaps it's better to have several good quality options to choose from.
Have a look at Ext JS, it is pretty good. If it is a commercial project you are doing it isn't free but not too expensive either. It also has a GWT version if you prefer that.
This is only for the front end but it is not too complicated to use any backend that can emit json.
CakePHP is pretty good

PHP - Javascript Controls

I'm currently developing (another) Open Source CMS in PHP and I'd like to use javascript controls especially for the admin panel. The question is, are there any open-source, freely distributable controls (for creating javascript Editable Grids, Trees, tabs etc ) that have an interface for PHP ?
I've experimented with ExtJs in the past but although its usability and beauty when it comes to implementing it with php, it's a frustration. I've also tried PHP-EXT and ExtPHP libraries but I was disappointed by their generated code, their limited implementation of ExtJs and lack of proper documentation.
Coolite is a nice implementation for .NET but I haven't found anything similar for php. That surprised me, taking into account the years of php development on the market.
Off course there's always the option of implementing different libraries for each component but this would become an overwhelming task, besides the incompatibilities and the difference in look&feel that are going to come up.
Any suggestions?
Thank you in advance.
I really like jQuery with their new jQuery UI. Also, browse through their plugins list for more tools.
But you might like mootools too.
Really the best thing to do is just to write the JavaScript interactions between your JS library and PHP yourself. Overall generated code wil never be fully changeable and most JS libraries take a mere day to learn how to use.
Best bet is to go with jQuery and jQuery UI as it has a lot of documentation and support.
You might also like the Yahoo! User Interface Library which might be closer to Coolite.
There is one framework I've seen for producing thick client web apps called Cappuccino. Might be overkill for what you want to achive, but the demos just look so tasty.

Categories