Build a text-editor in my website - php

Ok, I have a website that uses no Framework or CMS because it is a simple site that just displays some text. Nothing more, nothing special for what you would need a real CMS for.
But when I want to change some text I don't want to download the file, edit it in PhpStorm and then reupload it. So I wanted to ask if there's a minimalistic framework that enables this for me without too much time effort.

I had same problem with that.
I used CutePHP.
I suggest you to browser over here
Top 10 simple CMS

Why don't you write your own CMS then as that is exactly what you are describing.
It should be a simple matter of creating a database table:
create table mypages(url VARCHAR(128),content TEXT)
You can then echo the content field as your page when needed.
SELECT content FROM mypages WHERE url='{$_SERVER['PHP_SELF']}'
Updating could be as basic as dumping the content into a textarea in a simple HTML form. Handle login with .httaccess for simplicity and Robert's your father's brother. If you have problems writing the code then just ask here!
I reckon this is an hour or two of programming at best.
I do think that time would be better spent though, if you were to learn to use Drupal instead. Drupal is free, takes about 10 minutes to install and about 6-10 hours to get your first web pages running properly. Less if you are not fussy about themes. It is easy to use and yet was good enough to power the White House site.
Better yet, it's written in PHP so its easy to follow and understand.
The real advantage of doing it this way is that though there is a very steep learning curve as for any major CMS, once you are up there, you can do so much more so much faster. You need only learn it once, after all.

Related

Do I have to work with code when building websites in Drupal

I know HTML and I know some PHP. But I would like to know if professionals do use code a lot when developing websites in Drupal. My experience from Drupal is that you don't have to write any PHP or HTML at al and that you can do everything from the admin menu. But since I'm new with Drupal and currently learning Drupal 7 I would like to know what opinion others have when it comes to Drupal and building websites.
When are you using code in you are using code at all?
As a professional, yes, I use PHP and HTML all the time while working with Drupal. I'd say that roughly 70% of the time is doing PHP, 5% is configuring the modules via Drupal's interface and 25% is testing. The numbers given are, of course, just to let you see how important PHP coding is when I'm doing a Drupal site for a client.
Theme development cannot be done without PHP + HTML + CSS + JavaScript coding. Drupal 7 requires more work than Drupal 6 due to an increased template engine granularity.
If there's no contrib module that suits you, you need to write your own or tweak an existing one (PHP and SQL, sometimes JavaScript). This is true especially of Drupal 7, as there are still many modules from D6 that have no stable version for D7.
Once you get more experienced, you'll come to this conclusion:
Drupal carries you 90% of the way, and the remaining 10% is up to you.
Not every module will solve the particular problems of your project.
The upside is the API is pretty thorough and most (just about anything) is solvable in a simple module, template override, or hook.
Unless you are building simple sites, you will probably do some coding. At the very least you will modify existing code to make changes to existing modules. More likely you may need to create new modules. Even though existing modules about, finding one that always does exactly what you want may be difficult.
Short answer: Yes, you will have to write code.
Here's why. Drupal, on it's own is all well and good. It does what it needs to do, however when setting up a website professionally you can't use the default themes, most clients wont want this. Quite a lot of clients would prefer a unique theme, which involves you creating one. This would involve some PHP programming in order to get it working with Drupal.
Not only that, but writing and or customizing Drupal plugins will most likely be necessary.
In most, if not all professional environments the 'default' just isn't enough.
I'm on the newer end of the Drupal spectrum. I've built about five sites. I built my first several sites using little or no PHP (I did use ample CSS and HTML markup). So I would say that it is possible to build in Drupal with little understanding of PHP.
But. Drupal is a complex system which seems to favor developers, as opposed to end users who may favor the click together approach (although this is something that may be changing).
I've found that the more I understand the codebase and the API, the easier it is to get what I want without having to wade through a giant body of contributed modules. The repository of contributed material in Drupal is fantastic and covers a lot of ground, but isn't always actively maintained and may not do just what you want.
I think a good place to start is understanding the hook system, the Form API, and the menu system, as well as how to generate queries. That's all more back-end stuff. On the front end: the template system, template.php and the preprocess and theming functions.
Checkout api.drupal.org.
No.
Drupal and its 90 million modules love checkboxes and dropdowns and textfields etc etc to set everything up. For most features, you won't need PHP and only very little HTML.
I consider this a downside and a flaw, but some like it.

Should I use WordPress or go custom?

I'm taking on a relatively small freelance project and my client would like to update several portions of their site; photo gallery, calendar list, about page, and some event links.
My gut tells me to use something like WordPress and use "Pages" for these sections, but I'm worried about my client maintaining the formatting. Especially something like calendar dates and links.
They won't be doing any blogging - this is just so they can update those sections when needed (obviously).
But then I thought, what if I just roll my own CRUD for these portions, but I'm not sure if that would be necessary for a project like this.
So what would people out there use in a situation like this? How much control does one have over the formatting of content in WordPress? I'd like not to have to teach my client on when to call certain CSS classes.
Any help is more than appreciated.
EDIT:
Any idea how the top carousel of BungoBox was made in WordPress? Or don't you think it's possible and that is done manually?
I would stick to wordpress or similar CMS system. It will be a pain-in-the-arse, to take care of formatting (WYSIWYG for client), take care of security, make the administation pages nice and functional, and so on.
You will find a LOT of information on wordpress as a cms on the web, for example see here
Have you considered any other cms system?
From the description this is a site that would consist of just a few pages that the client would want to update? if so, I'd stick with wordpress myself. There's a ton of pre-written modules and themes already out there, and there's no sense "re-inventing the wheel". Also I've found in my travels that Wordpress leads the pack in being able to manipulate content to your will of all the CMS's and the available WYSIWIG plugins they have. Remember, if they cant' get their document to look just right, guess whose getting the call, and who will be expected to fix it on your dime if you didn't specify that in your contract (you are offering maintenance as an additional feature right?)
Now if the client is looking for a more robust system, a larger site then I interpreted in your writeup, then I'd look into more of a CMS system such as Drupal or Joomla. Avoid the trap that seems to nail PHP coders that it'd be faster to do it yourself; it'd have to be a lot of custom functioanlity to start looking at building it yourself from the ground up (and even then, there's enough frameworks to help)
What about something like Drupal? Never used it personally, but I think it's built for this sort of thing, whereas WordPress is kind of tailored towards blogs.
Definatly go with wordpress, drupal is just too heavy for the job and will take you much longer to configure.
If you are worried about your client ruining design with a WYSIWYG editor, just don't give them access.. keep them on a need to know basis for their own good.
Working with wordpress will free you from maintaining security issues and many other unpredictable-at-this-point cases of reinventing the wheel.

What script should I attempt first?

I've just got started with the basics (as well as a few intermediate aspects) of HTML, CSS and PHP. What is a good starting point to practice these 3 languages?
I was thinking of writing a URL shortening script but I was wondering if anyone here might have a better idea.
I am looking to develop something that would help me broaden my knowledge of the above 3 languages, but it shouldn't be too advanced that I wouldn't even know how to start it.
Any suggestions would be appreciated.
Whatever you write, if you allow users to input anything, prepared for it to get spammed and hacked mercilessly as soon as it goes live.
Therefore I'd suggest starting with something where you don't give end users any input ability. Something like an image gallery, or a CMS where you as the site admin can create the content, but end users only get to see the finished pages.
If you're feeling more adventurous, you could write a guestbook app, or something like that, but be warned that you'll have to learn quickly all the security aspects of allowing end user input. You'll need to learn how to block spam, avoid SQL injection attacks, prevent cross-site scripting attacks, and a whole bunch of other stuff.
That's all important stuff to know about, but perhaps best left to your second project rather than your first.
Some common beginner tasks are:
- image gallery
- message board
- phone book
- simple forum
These simple projects will allow you to get accustomed to the languages and prepare you for the next steps: security, optimization, user experience, and maybe other.
I recommend trying something very simple at first and finishing it. Only after that you should start something bigger, or better still improve on your first project.
A simple blog platform would be a potentially good second or side project, with the opportunity for enhancement as your skills improve and incorporating things you'll learn from other smaller systems. Start from a single-user blog without comments, and build things up as you go along. Gives you some more free reign to play around on the design (HTML and CSS) side of things as well, and you can always throw in some simple JavaScript as well.
I'll say that #Alin's answers are some good potential starter projects as well, and #Spudley's answer is a good one.
And above all else - have fun!
I support a few of these. I would also suggest you look into doing something for someone else, say a small project. One think I find with myself and those I've taught is that it's a lot harder to commit to something when it's your own project. You also get caught up in the details. When you're doing it for someone else, though, it minimizes the chance.
Also look into using a MVC framework as a way to learn. Good MVC frameworks will allow you to play around while learning how classes work in PHP. I'm sure there are plenty of questions regarding them on SO.
Finally, if none of that leads you anywhere, think of something fun you'd like to try, not matter the difficulty, and go with that. Even if you don't complete a project, there's a high chance you learned something on the way, and that's worth your time.
You can start by reading and do some examples from here http://www.w3schools.com, they have good explanations for everything you want to use in html, php and css.m
Here are a couple suggestions:
Guest book
Simple client / project management
No PHP script could help you with html and css.
You have to master these things separately.
if you want to practice with html and css - just create an HTML page that represents one of your site/script pages and use it to train your html,css skills.
And it will have absolutely nothing to do with PHP part.
Just once you have finished with HTML, you will need to produce the same text dynamically.
Make blog. One step at a time:
On the main page articles one after another. Store them in files.
On the main page only 3 newest. Access the rest of them by menu.
Add option to create new articles.
Add option to edit or delete them.
Restrict access to these actions by using logins and passwords stored in file.
Add option to comment articles.
Add option to remove comments only by administrators (those logged with login and password).

When is a PHP project too small for a framework?

I'm about to start on a small, static website project: no database or CMS required. Basically, a brochure website.
I used the CodeIgniter framework recently to develop a full-blown web application, and I'm wondering if it appropriate to also use CI for smaller, simpler sites.
Typically for a static brochure site I would write regular PHP pages with a few includes thrown in to save on repetition (i.e. HTML with a sprinking of PHP), but this time around I'm wondering if my new friend CodeIgniter might be able to streamline the development process.
Is it sensible to consider a framework for such a simple project, or is it overkill? I'm worried that I might be the proverbial carpenter whose only tool is a hammer, and sees every problem as a nail!
I think almost never, the needs change and come more with time... so it is better to have a good base using a framework to wait the future needs. but if your project will not have a long live time and your needs are reaaally simples then i think is not necesary use a framework.
I personally would never develop a site outside of a framework for anything more than a single page brocure-ware site. I work so much faster inside the framework.
I'm a Python/Django developer but here's my take.
I've done some small non-framework sites with PHP and I don't know how PHP frameworks compare to DJango, but if they're anything alike the fact remains that I'm far more proficient developing within a framework than to code something from scratch by hand.
It helps me stay organized if nothing more than giving me the VC of the MVC. Django provides me with a lot of built-in tools, like form handling, that make my life much easier even for small sites.
I'm going to presume PHP frameworks provide similar things, maybe not though.
You also can't anticipate how the site will grow over time. It's easier to maintain something built in a framework, and if you ever need to extend the site in the future it's nice to have some structure behind it.
Since I tend to either inherit bespoke frameworks, or write my own, I would peg it at about 3 pages: if it's more, then setting up a framework is worth it. And if it needs a DB, then odds are good you'll end up with more than 3 pages, anyway. :-)
I recommend Rapyd, a "minimalistic and rapid PHP framework".
How long is a piece of string?
I use CodeIgniter (specifically PyroCMS) for crappy 5 page brochure-ware but that is purely to let clients admin their own pages easily with a WYSIWYG.
Any client will say "Wow, news, contact form and I can get me some of that Twitter too?!" so I just dump it in there to save everyone time.
If you are developing from scratch there is no point if the content is static. Something like CodeIgniter helps with DB interaction, Form validation and the breaking down of multiple pages into logical chunks i.e Controller classes and methods.
If you have no db-content, don't handle forms and don't have many pages then there is litterally no point adding the overhead.
That said, try my Twiny framework for literally the smallest MVC framework around.
If you don't need a database, CMS and is just a simple static HTML/css/PHP page, I don't think you can go wrong creating a site without a framework. Plus, if you have been using frameworks for a long time, you can have a break and do "code for code" and have a feel what it's like to code from scratch :)
Site is never small if the client is there who may want to ask you to add more functionality at any time :)
For a simple site like that. why even use a framework why not use something like concrete5. Overkill? definitely. but hey it is easy and requires almost no coding so upkeep is a breeze.
The site would be up and running in less than an hour and it makes you look good in the eyes of your customer and that can't hurt.!
I don't think any project is too small for a framework, I think some frameworks are too big for small projects. Everyone hopes their website will grow. So no matter how small the site is now, growth will be easier to manage if you start with a framework.
The only case when framework would be an overkill is with a throw-away scripts, such as when you need to quickly automate something that you won't need to do again ever. For anything that will enter execution cycle more then few times framework is a probably would be better.
If it requires under several hours of work - then it is small. Anyway if you plan to devote more than "several hours" - definately use a framework AND a control revision system.
It depends. If you're positive this is all the site you're working on will ever be, or migrating when future needs arise, then I can't see why there would a reason for using a framework, unless you feel more comfortable working with one.
As a personal example, I recently worked on a semi-static website, for which I put together a minimal framework which worked as a caching preprocessor for static html, inserting common html-elements into preset places. This allowed for some dynamic content, yet still using only static html for content.
I'd say you're answer lies within a formula consisting of future development needs, your own working preference, and performance.

What language to use - simple form + MySQL + admin page

Apologies if this is not the right place to ask but here goes...
What should I use to create a simple web application for our website?
I'm the IT guy for a small non-profit. On our website we have a page with a large form in which users can fill out information on an application form. The information gets sent to a MySQL db. This data can then be accessed and edited by a couple of members of staff behind a logged-in part of the website. There's only two dbs being used: the main one with all the data and the one used for login details for the web app. It's all done with PHP and functionally is fairly simple - just a form with lots of fields to collect data and a basic secure "manager" page to do a bit of stuff with that data.
The problem is that we need to make changes to the app, and to extend its functionality quite a lot. I have a little bit of experience playing around with PHP but I've taken one look at the code used and decided it'll take too long to decipher it and see what's happening where. The code is uncommented and a bit of a mess.
I'm starting to think that rather than investing time to relearn what little I knew about PHP and untangle all the code, I might invest the time in learning another language and/or framework to get this done. I want the resulting web app to be a lot easier to maintain in future by me or anyone else who comes along and has to make a change.
Would you recommend using Django/Python for a project like this? Zend/PHP? Just PHP and notepad? I want the app to be done fairly quickly so the less steep the learning curve the better. Many thanks for you time.
Another good PHP framework is CodeIgniter.
They also have a good webcast that outlines how to begin with the framework as well as create a simple blog [tutorial].
I would recommend a PHP framework, such as CakePHP. Spend 20 minutes of your time and follow their blog tutorial.
Using PHP alone can be tricky, especially when you will have to deal with security issues.
From what I can see you have asked 2 questions.
1. Should you maintain and extend the current code base or do a rewrite?
Rewrites always take longer than you think. And even if you do the rewrite to avoid learning the codebase you would still need to learn the current codebase to ensure you capture the current functionality before adding any new features in the rewritten codebase.
I would keep the current codebase and maybe do some refactoring as you add features.
What should language and frameworks should you use?
I would stick with PHP, CakePHP is a solid framework and so is Zend. I would read up on both and do a couple of tutorials and make your decision.
As Anax states, I'd suggest that you look to use PHP. If code is already implemented then you have a start.
PHP isn't hard to re/learn. I know some don't like it, others like it but simple fact, either way it isn't hard to learn. But, more importantly consider the following:
You obviously have access to the hardware stack required to use PHP and MySQL. Introducing a new language/technology may cause unforeseen issues with getting a production site set up.
Now this doesn't mean that you can't write certain components in other languages. You could, if you were so inclined. But you probably shouldn't be so fast to get rid of PHP just to learn another language. Do you have important (technical) compelling reasons to use something other than PHP?
If you are mostly concerned about the spaghetti code in place, you can get that anywhere -- even new development. Better to re-factor the code and fix and add to what you have than start from scratch.
I can offer some general considerations:
Whatever language you choose, get a good IDE for it. Having automatic syntax validation and code completion helps a lot if you're a beginner. Don't use plain text editors.
Teaching yourself how to code well will make for a very frustrating experience unless you have a lot of patience. This generally comes from being really sure that you want to do it.
Be very conservative in your time estimates. Having many setbacks is guaranteed if you're a beginner.
Start out by focusing on reading about writing code, not focusing on writing code. If you're learning Python, read the official tutorial first. The same goes for PHP.

Categories