Pcphpjs

From ProgClub
Jump to: navigation, search

Pcphpjs is the ProgClub content management system for the Jsphp project. That's the software that allows you to manage and develop JavaScript functions that emulate PHP functions. It's a new version of phpjs with some planned bug fixes and improvements. For other projects see Projects.

Project status

Released, but there's stuff TODO.

Contributors

Members who have contributed to this project. Newest on top.

All contributors have agreed to the terms of the Contributor License Agreement. This excludes any upstream contributors who tend to have different administrative frameworks.

Upstream contributors:

  • Doctrine contributors
  • CodeIgniter contributors

Copyright

Copyright 2011, Contributors. The pcphpjs software is licensed under the New BSD license.

The pcphpjs project is the software than manages the jsphp.co web site. It's an open-source content management system for a JavaScript library. The JavaScript library itself is licensed separately under the MIT and GPL licenses. These are the same terms as used by the upstream developers as explained on their license page. For more information about the JavaScript library check out the Jsphp project.

Pcphpjs uses the Doctrine ORM toolkit which is licensed under the LGPL.

Pcphpjs uses the CodeIgniter web-framework which is licensed under the CodeIgniter license.

Source code

The repository can be browsed online:

http://www.progclub.org/pcrepo/pcphpjs/

The code for pcphpjs is publicly available from svn:

http://www.progclub.org/svnro/pcrepo/pcphpjs/tags/latest/

Or privately available for read-write access:

https://www.progclub.org/svn/pcrepo/pcphpjs/trunk

Links

Development links

phpjs related information

Doctrine related information

CodeIgniter related information

Doctrine with CodeIgniter information

JavaScript testing frameworks

Release notes

Hey everyone. You haven't heard from me for a while, because I've been very busy implementing a web-site in PHP and MySQL. This is the most substantial PHP/MySQL (AKA: LAMP) project that I've ever done, and I did it to research the technology and hone my skills, as this is the technology the Blackbrick will use.

You can see the newly released web-site here:

http://jsphp.co/

Basically the site is a Content Management System (CMS) for a JavaScript library that provides the PHP API. This means code written for PHP can be more easily migrated to JavaScript, something I did when I created a JavaScript and PHP implementation of the Blowfish encryption cypher, pccipher:

https://www.progclub.org/wiki/Pccipher

The jsphp.co web-site has a number of features where I got to try out different technology. I used a number of open-source frameworks and toolkits, being:

  • CodeIgniter - a PHP web framework
  • Doctrine - an ORM and DB management tool
  • YUI - a JavaScript library including a rich text HTML editor
  • jQuery - a JavaScript helper library
  • QUnit - a JavaScript testing framework
  • HTMLPurifier - a HTML parser and filter
  • WikiDiff3 - a diff tool from MediaWiki
  • Slib - Blackbrick's PHP web toolkit

We're using the following technologies:

  • HTML5 - document format
  • CSS - document layout language
  • JavaScript - client side programming language
  • Graphics (mostly PNG) - as multimedia as we get
  • PHP - server side programming language
  • MySQL - database server
  • Apache - web server
  • Linux - operating system
  • Subversion - version control system

The jsphp.co web-site has implemented the following features:

  • Pages - there is a CMS in place for managing the content of pages, such as the contacts or downloads page
  • HTML comments - a rich commenting system that allows for threaded conversations, replies, edits, rich text HTML editing with WYSIWIG support, and the ability to comment on functions, versions, tests or pages in the site. Also, there is a facility for user comments (must be logged in) and anonymous comments (no need to login).
  • Session management - users can login to the system to enable advanced features
  • Categories - functions are categorised
  • Functions - functions are the core of the library
  • Menus - there are drop down menus available
  • Editing - functions and other code and data can be edited via the UI
  • Benchmarks - functions can be benchmarked to compare the performance of different versions
  • Revisions - there is a complete version control system with annotations for functions and tests
  • Diffs - the differences between function and tests implementations can be easily shown with a graphical diff tool
  • Developer attribution - we record and report who has contributed to the various functions, including upstream developers and local developers
  • Dependency management - the dependencies for functions can be modelled and supported for automatic loading and inclusion in downloads
  • Downloads - there is a tool for packaging the library as a download
  • Links - our database records useful links to integrate with the upstream project and PHP documentation
  • System administration - a facility for creating, updating and deleting of categories, functions, users and developers
  • Error logging and reporting - a system that records any errors encountered during processing so they can be reviewed
  • Data import - there are facilities in place to import function code and contributor information from the upstream developers

So I've learned how to do all that in PHP, and I'm pretty pleased with my effort. Of course the actual JavaScript library the system has been instituted to manage is itself useful too, and hopefully this tool will end up being the platform for an open-source community.

All told the web-site took me about two weeks to create, from nothing at all to version one.

TODO

Things to do, in rough order of priority:

  • Pagination with Doctrine
  • Implement scriptify and deploy
  • Refactor view links on models that aren't Jsfunction, Fnversion and Testversion.
  • Allow user to subscribe to comments, threads and functions to get email notifications if things change.
  • Model get by one-to-one relationship functions
  • Set access key on all form buttons
  • Create a 'phpjs' user with disabled password and attribute function imports to their account
  • Create test html pages to submit malformed requests and see they get handled properly
    • Check missing fields
    • Check invalid fields (e.g. string instead of integer)
    • Check script tags/HTML injection
  • Create RSS feeds for:
    • Comments
    • Threads
    • Functions
  • Create an activity log
  • Improve/complete comment creation and editing
  • Support pagination for various content (e.g. error lists, comments?)
  • Use UTC dates in database
  • Improve account management: i.e. forgot password, change details, email alerts, timezone, etc.
  • Add support for user/session timezone
  • Create subversion repository with development and production branches

Done

Stuff that's done. Latest stuff on top.

  • JE 2011-12-24: Function status management; create, update, etc.
  • JE 2011-12-24: Copy in pccipher/simpletest and test scriptify
  • JE 2011-12-24: Factor slug into slib get_slug
  • JE 2011-12-24: Code review entire codebase with a view to:
    • Removing XSS vulnerabilities
    • Removing HTML injection vulnerabilities
    • Having consistent controller/action/view naming and implementation
    • Fixing input validation
    • Fixing error logging
    • Fixing redirection (start using 'goto' where possible)
  • JE 2011-12-24: Add 'comment' links to various pages
  • JE 2011-12-24: Finish upstream contributor management
  • JE 2011-12-19: Design and implement database (has been continuous)
  • JE 2011-12-19: Create database creation/upgrade scripts (sort of mostly done, using Doctrine)
  • JE 2011-12-19: Create a 'wiki' like front-end for users to submit and test patches
  • JE 2011-12-19: Create unit testing facilities
  • JE 2011-12-19: Create benchmark facilities to compare versions, mostly to compare performance
  • JE 2011-12-11: improved basic user, category and function management functionality
  • JE 2011-12-11: created database management scripts
  • JE 2011-09-22: released basic account, category and function management functionality
  • JE 2011-09-22: found Integrating Doctrine 2 with CodeIgniter 2
  • JE 2011-09-20: imported CodeIgniter 2.0.3
  • JE 2011-09-19: imported Doctrine ORM 2.1.1 and worked through Getting Started
  • JE 2011-09-07: created project page
  • JE 2011-09-07: created project in svn

Notes for implementers

If you are interested in incorporating the ProgClub pcphpjs into your project, or if you're setting up a Pcphpjs development environment, here's what you need to know:

MySQL configuration

Creating the MySQL user and database

  • Using phpMyAdmin:
    • Click Privileges
    • Click Add new User
    • Username: Use text field: jsphp
    • Host: Local
    • Password: Use text field: (Click 'Generate' for a new password)
    • Database for user: Create database with same name and grant all privileges
    • Click 'Create User'
    • Copy the SQL commands that were used (they will be displayed after you click 'Create User') and paste them here:

Loading the MySQL schema from database export

  1. Login to PHPMyAdmin on your local server
  2. Create a new database
    1. Click on the databases tab at the top of page
    2. Enter a database name of your choosing and click 'create'. A good name for this particular database would be "jsphp-dev".
  3. Once you have created the new empty database click its name in the list of databases on the top left of the page so that you are 'inside' that database.
  4. When you are 'inside' the database click the 'import' tab at the top of the page
  5. Browse to the database file you would like to import and click "Go" (the default settings should be fine).

Loading the MySQL schema from scratch

(John will document this later)

How to reset the password of a MySQL user account with SQL

  • SQL to reset a user account password for all hosts, e.g. the 'root' account

Samba configuration

Sharing your home directory with Samba

  • sudo apt-get install samba
  • edit /etc/samba/smb.conf

Setting the password for a Samba account

  • sudo smbpasswd adriano

Pcphpjs configuration

Checking out pcphpjs trunk from svn into home directory

Proxies directory permissions

After you have configured your database you will have to CHMOD the following directory to allow read/write access for the www-data group-

pcphpjs/src/lib/ci2/application/models/Proxies

You can either use the terminal or the linux GUI.

Using the terminal
cd /pcphpjs/src/lib/ci2/application/models/Proxies
sudo chgrp www-data 
sudo chmod 775
Using the GUI
  • Navigate to the proxies parent folder
  • Right click the proxies folder -> properties -> permissions tab.
  • Change the drop down box labeled "Group" to "www-data" and the very next drop-down to "Create and delete files" and click OK.

Not setting these permissions correctly or not setting them at all will most likely cause a server error when trying to navigate to index.php. If you are encountering such an error, checking the permissions of the proxies folder may help.

Creating config.php and database.php

Editing database.php

  • Navigate to pcphpjs(your project folder)/src/lib/ci2/application/config
  • Open database.php with a code editor
  • Scroll down to the bottom and input the appropriate values for-
    • Username - this will be 'root' if you haven't configured separate users
    • Password - the password for the user above
    • Database - the database name you have chosen, in my case 'jsphp-dev'