How to quickyly find completed PHP website source code in Github? - php

I am new to Github, and want to find some good written PHP website application source code to read. But simply type 'php' as keyword and search on Github is not that effective. Is there any better way to do it?
Also, are PHP frameworks source code good to read and learn?

I think on github there is also a lot of bad written code. I can tell you that maybe working with an CMS might be something for you. While creating Plugins for CMS systems you learn the CMS itself part by part. This way you may understand why things are how they are.
In general, noone simply starts reading Code. You read Code to understand how you interact with an external system.

Related

PhpBB's automod like software for php

I have looked and looked all over to find a way to make something similar to PhpBB's automod system they use for their software.
I cannot seem to find anything similar to this with the whole xml find and replace code updater and mod installer.
I may just be typing in the wrong keywords in Google, but does anyone know of any system like this available before I start trying to make my own?
EDIT: I mean more like a code updater. For example find and replaces in a php file.
FIND:
?>
ADD BEFORE:
echo "this is text added before the ?>";
I realize this could be done with str_replace but there is surely a system out there that already does this reliably.
The reason that a system doesn't exist outside of phpBB is because it's an incredibly poor way to manage modifications. Your question does not make it clear what you want to gain from this, but since it is your own code, you should definitely not look to copy something so awful.
For “patching” code
If you want the ability to apply updates to your code, then you should look at handling it through version control. For instance, you could develop and test in a local git repository, and once you are happy, push the changes to the server. You have many options here from a basic update script to a fully-fledged Continuous Integration solution.
phpBB have implemented a solution for patching code on your live site via a Web interface, which has many issues with security, verifiability and maintainability among others.
For exposing “plugin” functionality
If you want the ability to register plugins in parts of your code, then you should architect your code as such to allow it to be handled easily. Wordpress, MediaWiki and other projects can help you write such a structure.

getText crowdfounded translation

I'm looking for a script (there has to be one) that help me to let me user translate my getText based PHP project.
Right now, I don't have time to create a solution on my one, so I were looking for some proper open-source solution using Google Search, but I could not find anything.
There are a lot of commercial solutions for this, but I would like to use a simple PHP alternative on my own server. It does not have to have a lot of features; I just want to select the languages I need and let the people translate and check translations.
I don't know of any solutions in PHP, but there are several open source projects for web-based translation tools. For example:
Weblate is based on Python/Django and supports Git integration. I think it is used by phpMyAdmin, so it should be suitable for PHP projects.
Zanata is written in Java and used by JBoss.
I also found SimplePO on Google Code which is written in PHP, but it does not seem to support plural forms. There is also a more recently updated fork on GitHub.

Is there an argument against using a CMS?

I'm thinking about rebuilding my website from scratch, but this time, using a CMS. Everywhere I turn people tell me to use a cms, but it's only now I'm really considering it. My site isn't too complicated. Is this a good idea in terms of workflow? I'm the only person who will edit the site, so if it's just a matter of workflow and efficiency, should I just convert now before it gets really big?
Sure, a few come to mind.
Deployment complexity. Many CMSes require a database, which means running a database process somewhere, and backing that up, as well as the rest of the code and assets for the site.
More space will be required to hold the CMS code for the manager, framework, libraries, etc.
Bloat could come into play, the CMS may, and likely would, implement features you have no use for.
Additionally any CMS will have some kind of limitations, some things will be more tricky to do than others when compared to a mostly static site.
Just read the code. That's often all the arguments you need. (If your needs are really simple and you don't need plugins and you don't need to write any code yourself I'd still use a CMS, though)
If your site is mainly a design showcase, and doesn't have real content in it, then a CMS will only get in your way and make things harder.
Otherwise, it will mostly be of help.
Along with everyone else's statements. If it's just a small site you don't necessarily need a CMS, but if you are wanting to use a CMS for client projects in the future, why not start now.
Deployment. If you're doing some big changes to your site or testing something, you'll probably want to try it out locally with a development copy of the database. Once you're done, how do you get everything to the live site without overwriting, say, comments that were made on the live site since you created a development copy?
Specialization. CMS's are great for some things, but they're bad at others. What if you want to add more complex functionality to your site? It might be a plugin or module at first, but soon you're writing all this code and you realize you should have just used a framework and built the CMS part yourself.
If it's a simple static site with a single editor and without any aspirations of using complicated functionality and you feel confident enough in your web language of choice, then go for it. Even if you don't feel confident enough, it should be a good challenge.
Write some minor templating so that you can separate your code from your design, have some simple way of adding articles or blog posts or whatever - it could be as simple as including text files from a directory.
Using a CMS, even in their modern and quite usable state will require more resources, hardware-wise. and will probably have a steep learning curve. It will also require maintenance and dilligent security patch application as new vulnerabilities appear. On the other hand a CMS can get you up and running with a basic site quickly, and grow with your needs if you feel like enriching it, as you get to use its large variety of ready made plugins and extensions. You want blog comments with users logging in via OAuth? No problem. RSS? There's an extension for that.
Bottom line is, if this is a simple static site with a single editor as you describe it, it should be trivial to set up some code to run it. You'll spend as much time on its template design as you would on customizing a CMS's template, avoid the initial learning curve a CMS requires, and not worry too much about the resources and maintenance a modern CMS requires. You will, however, be limited in functionality and future ideas by what you can write or integrate yourself.
It depends somewhat on the purpose of the site.
If it is a means to an end of getting information posted on the web, then adopting something like WordPress will quickly get you going, and provide lots of extra functionality that would take a fair amount of time to build in - e.g. stats, feeds, remote publishing etc. There are a few basic steps you'll need to go through setting up self-hosting on a shared web-hosting package e.g. creating the DB and unzipping the files etc but fairly straightforward really. And the time you save administering your website can be focussed on other things where you're making a difference or doing something different to everyone else.
However if your purpose is in part the learning experience of developing the functionality or you have unusual requirements that aren't in a standard CMS, then there is an argument for developing your own.

How can I protect my PHP code?

I have developed an application and now I would like to hire some programmers to work on several pieces of it to upgrade and tweak it.
I have read other questions/answers here but they are mainly about obfuscating the code which is something I do not want to do (as I need them to read it and tweak it).
What I'm basically asking is, what is the best way to structure my code so I will have to expose only what I have to?
A good example for me is a webapp called RightNow which I'm developing for at work, what they do is they let you play around with all the widgets (you can create/edit/remove any widget) but the core of the application is in folders I do not have permissions to.
After you do your coding on the widgets, you then 'deploy' the application and it goes live. I have no idea what the deployment actually does behind the scenes, but this is one practice (not sure if it's the best) which allows the application owner to have control over the core of the code but still allow development for it.
Is there a better way? what do you think?
First you can use a version control software like SVN for example.
and then you can have copies of the code, one for testing and one for the your programmer. When the programmer is done changes and tweaks, the testing code gets updated first and when the test are done the live application gets updated.
you can obfuscate your core classes(ones that you don't want to expose). and other developers can include and use them at the same project as long as you provide a nice api to your classes.

What is a logical way to learn PHP for Drupal and WordPress coming from Ruby on Rails?

I'm a self-taught hacker who's still not great but I can get simple crud apps working with Rails and I appreciate the beautiful design of Ruby. Ruby was my first programming language.
Now I'm getting into Drupal and WordPress and starting to want to develop my own modules and plugins. But when I look at PHP it looks daunting--probably because Ruby has spoiled me.
All that said, I do want to try to pick up enough PHP to work with modules/plugins. Other than constructs like datatypes, operators, variables, etc. What high-level concepts do I need to know? I've been indoctrinated to OOP and MVC--will this hinder my PHP learning?
I've seen many books on 'Rails for PHP developers' but I've seen little about going the other way. I'd appreciate some logical tasks or goals for an 'advanced' novice in web development.
Thank you.
What is your goal?
If you really want to learn PHP, I think you should stay away from Wordpress and Drupal for a while and start with a basic tutorial like http://php.net/manual/en/tutorial.php or http://www.tizag.com/phpT/.
If your goal is to learn Drupal and/or Wordpress, then I wouldn't focus on the php part (yet). I'm not a Wordpress expert, but for Drupal I advise you to learn what Drupal has to offer without any coding. I read a quote today saying "Drupal is oriented for sitebuilding first, coding later." I think that's spot on. I have seen experienced programmers who install Drupal core and start hacking around it instead of working with it. Once you have learned the site building and configuration part, start working on your php skills to add the small bits and pieces you're still missing.
I'd start off with creating a few themes for wordpress. Don't waste too much time on the design, just focus on how to get it running. Really focus on "the loop". It's a simple concept that is the basis of wordpress and will show you how straight forward php is.
Drupal is big. It will confuse and slow you down in terms of learning php.
I started with http://devzone.zend.com/node/view/id/625
Get the basics of php down, learn the loop, develop themes then maybe move onto drupal.
There is not really any high level concepts in PHP you can learn. Closures became available just recently, but that is about as advanced as it gets.
You already know MVC and OOP, which are used in some frameworks (CakePHP, Joomla). Wordpress, however is not well organized and clean. I don't know about drupal, though.
I think CakePHP is the most Rails-like PHP framework. The tutorials in the manual are quite good, so you might want to read through them to see how PHP can look in an OOP, MVC environment where you feel at home.
http://book.cakephp.org/view/1528/Blog
Drupal might not be the very best place to get started.
First: The php manual is also an invaluable resource:
http://www.php.net/manual/en/
and you might be best served by going through the "getting started" section:
http://www.php.net/manual/en/getting-started.php
I would breeze through that very quickly just to get a feel for things.
Once you've gotten the basics, I would move on to picking a framework for the next step:
There are tonnes of MVC frameworks out there.
This thread discusses frameworks that are similar to Rails:
https://stackoverflow.com/questions/117406/which-php-framework-is-closest-to-ruby-on-rails-cakephp-codeigniter
There is also PHP on Trax, which should be similar to Rails:
http://wiki.phpontrax.com/index.php/Main_Page
If I were you I would pick a framework similar to what you are used and go through the accompanying tutorial.
Once you are more comfortable with PHP, you can start looking into some of the Drupal tutorials; for example:
http://drupal.org/node/206753 (Creating modules - a tutorial: Drupal 6.x)
Finally: don't be afraid to take what you have learnt from Rails and apply it to your PHP. PHP is a pretty loose language which lets you write as good or as bad code as you like. Knowing language like Rails or Python should benefit your PHP a good deal.
For example:
http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html
No ruby programmer will ever need an in depth PHP introduction. Ruby is - beneath the surface - much more complex.
To get started:
setup a default apache
put a index.php into docroot
put
start writing a small blog application (embrace spaghetti code here[info])
start to refactor it into a small MVC style app
For online help: The PHP.net manual is very good. You will have a hard time to find things that are not covered by it, while you learn PHP.
You wonder about PHP OOP? You will be kinda disappointed that there's not much to learn (in contrast to ruby).
[info] You can argue that it's probably a bad idea to tell anyone something like that. But it's the way PHP works and you should know your tools in every way.
PS: Stay away from globals.
PPS: Use PHP as template engine.
From a Drupal POV, the following document, while dated, will prove illuminating: http://drupal.org/node/547518
For the OP, the above might be overkill until he/she gets familiar with Drupal. Nevertheless, it is a good read.

Categories