How to implement version control inside a web app? - php

I'm building DMS (Document management system) using PHP framework Laravel.
One of the requirements is allowing users to version control files, close to what google docs does.
I've been searching for days without any clue, I don't want to re-impalement the wheel, there's a lot of really good VCS already including git which I'm thinking of utilizing it using php to implement the versioning features.
I just don't know how to start or even my way of thinking is valid!

What you need is real-time system (achieved via socket programming) so that everyone is updated about the contents in realtime; also who is doing what: Like if there are two users A and B and they have opened the same file then A should know what the B is doing and vice versa; you would use client events for that. Have a look here:
https://laracasts.com/series/get-real-with-laravel-echo
Or
Look into Web RTC: https://webrtc.org/
GIT is a different thing given your requirements what I understood.

Related

Node js/Express to replace LAMP

I need help from you NodeJS ninjas. I am starting to learn it, after doing a good amount of LAMP stuff. I have written several systems in Apache/PHP/MySQL for a small corporate intranet (including things like a ticket system, employee scheduling, production reports, financial reports, etc).
So, in LAMP world, I start the Apache and MySQL engine. Then people go to their browsers, type the server IP and browse the different systems I've written for them based on the folder in htdocs.
I am trying to think what the equivalent would be in a set up with NodeJS, Express using the MVC model (something I am also new to). Two main questions:
Since I have several systems (employee scheduling, financial
reports, etc), would each one of these have their own middleware for managing, with their middleware rules and all that? or would they all run under just a main thread? (load balancing is another thing that came up).
What would the folder layout be? XAMPP had the htdocs folder and the folder structure was whatever I wanted.
From what I've seen in most tutorials, an option for a folder layout is:
-app
-- controllers
-- models
-- routes
-- views
-config
-- env
-node_modules
-public (I imagine the systems I implement would be on here?)
-server.js
Thank you for your help, I am still a complete noob, but I am excited to get into this.
I come from LAMP stack word and moved to nodeJS 2 years ago. A lot changed since then.
Things you need to know for nodeJS vs PHP :
nodeJS runs under google's JavaScript V8 engine.
nodeJS is ingle-threaded. PHP is multi-thread. That means any modification to a global variable, if there's any, is seen by all the connected users.
nodeJS with express alone is not MVC since MVC is a architectural pattern. You can if you want create folders to define a MVC pattern or hMVC pattern (depending on your needs). A bigger frameworks called SAILS does native MVC for you.
to start a nodeJS project, you have to cli node yourApp.js. That said, there is a better way to start a project using a script placed inside package.json managed by npm or using other npm package such as nodemon. There is no specific folder to start a project like PHP since PHP is managed by Apache and Apache is configured to have a specific folder for html docs.
Other things to add :
Javascript uses EcmaScript as scripting language. The version 6 of ES was finalised in summer 2015, and all browsers still doesn't native take it in charge. Since nodejs uses google's v8 engine, it's still based on ES5.1 or experimental ES6 with --hamrony flag calling node in cli. Since node5 many ES6 features are implemented but still not all are.
NodeJS is asynchronous, and async call are HARD to learn when you come from php word. You will need a lot of practices. I suggest you go read module pattern and revealing pattern.
I hope I have answered you'r questions

How to configure subversion, for web application development, to limit developer access to source code

My team has been working on a web application based on php, msql for backend and html,css,jquery for front end. We have been working for quite sometime now without version control. The project has become quite large and complicated now and feel that it is time to use some sort of version control ( vc ).
We have been reading quite a lot about vc and have found several techniques that people have suggested. although it might be a perfect method for them. it does not effectively apply to our case.
our application is split up into various modules and we have outsourced work to a few freelancers. freelancers work independently over front end or back end depending on their skill. The work has been happening over a Private Network so far and we would like to shift to an online system.
Now the problem is that we cannot distribute the source code for the entire project to all developers. developers are only allowed to work on some common libraries and their respective modules.
Hence we cannot allow the entire project to be downloaded onto each developers Local machine. Thus we need to find a way for all developers to be working on the same branch OR on the trunk. to be able to access only certain sections of the code and on saves/commits be able to check how their changes have effected instantly.
Is there a way the above task can be achieved ? for a web application ? using a version control like subversion?
To summarize, the features we are trying to implement are as follows.
Instant effects on save/commit ( When each developer saves/commits they should be able to test the effects like normal through the browser instantly )
Limited access ( Each developer can access only a specific part of the project and not the whole project. )
Online repository / Online copy - ( we are working on a VPN connection, and would like to have the website work on an online copy. so when a commit is made, the developer can view his changes online instead of the VPN )
after a lot of searching online we were able to find the below possibilities. But not sure if it is the right way to go.
For instant effects --> Entire system is checked out in a webroot folder ( eg. wamp/www/projectName ), a bat file is called to update the current system in the webroot, everytime a commit is made, by using the post-commit hook.
Limited access --> All development for all developers happen in the trunk OR a Development branch, developers can access their respective sections, lock it if needed and commit changes when they are ready to see its effects ( note still in dev branch ).
tags are created whenever a stable release is created. these Tagged copies are never modified.
Is such a configuration achievable using subversion or should we look at other open-source version control tools ?
Trying to prevent devs from accessing the entire source tree seems a bit misguided to me. Is it company politics? Don't you trust your developers?
In any case..
The easiest way to achieve what you want would probably be to put each module into its own repository (svn, git, whatever). Then you can selectively choose who has access to which repo.
Post-commit hook, which unconditionally "do site" is in a common not-so-good idea: developer can commit semi-finished code and even don't think about testing it
Make your Working Copy public, when site became public - not-so-good idea from the POV of security and IP. For SVN 1.7 to move WC-root outside web-root is much better idea
If modules are splitted to different directories, you can create repository per module and "super-repository", which, with svn:externals, combine repositories in Project
Path-access inside tree can be easy controlled (in http-repo) by authz_svn_module
Enable creating private personal short-time branches for developers ("shelves"), it helps to avoid (with 1) huge messed up commits
Firstly, I'd recommend reading the "Continuous Delivery" book (website here). It provides many examples for how to set up this kind of thing.
Secondly, yes, SVN allows you to assign permissions on a folder level as well as repo level (but read the "do you really want to do this" section).
Thirdly, making sure developers have up to date copies is something you should instill by discipline - "before starting work, and before committing, run svn update"). Post-commit hooks have a nasty habit of breaking stuff, and you're not preventing commits which break the build.
Fourthly, I'd consider setting up a continuous integration server (also described in the Continuous Delivery book). This makes sure you have a clean, working build whenever you put together the work of your developers.

PHP Automated Deployment and Testing

I asked a question here on automated deployment of automatically deploying java code.
Our back-end Java API is accessed by a PHP web app. It would be nice to be able to automatically deploy this web app (along with static files like CSS, JS and images) to our web server while performing automatic testing on PHP code. Is there something similar to this for PHP?
I also wonder if as part of this automated testing you can check that each actual page loads without a fatal error. I am sure I read about a google project which allows you to write page tests e.g. click on link a, go to page b etc etc.
Thanks
You may want to look into using Phing for deployment which has features that allow testing with PHPUnit and/or SimpleTest
Maybe this question handling deployment strategies can help you.
Additionally, but maybe gone too far, tools like cruise control may help you to apply continuous integration, too.
PHPUnit with ant was my way to go for automated testing, which could be a vaild option for you, too since you're obviously using some java already :)
Since you're working with Java, you might consider using Hudson (also mentioned in your other question), which has the ability to execute build tasks consisting of several 'steps' One step step could be unit testing your Java App, another unit testing a PHP app, yet another deployinhg Java app, and another deploying a PHP app (and you could add some more ;P )
It has a Maven plugin, so you could actually use your existing Maven scripts.

In search of opinions on web based version control systems

Researching various open source, web-based document management/version control systems. I've checked google/questions here, etc...
I'm looking for a lightweight web-based (apache) document mgmt/version control app that runs on top of SVN.
I need to have the ability to:
have multiple users checkin/checkout
have a workflow (when userA checks the file in, and finishes the app passes it to the next person, etc...
the app needs to allow me to have a structure where the files can be moved as a group. the files will be changed on a monthly basis
app needs to have a access/premission control system. some people can see certain files, and perform certain actions on the files
I imagine that I'm going to have 40-50 people dealing with the different files. I imagine that I'm going to have 2000-3000 files that have to be massaged.
I'd prefer that the app be php based if possible, as opposed to a straight java app.
Thanks
I suggest you take a look at Subversion:
WikiPedia: http://en.wikipedia.org/wiki/Subversion_(software)
Mainpage: http://subversion.apache.org.
I honestly don't know if it fits all requirements that you've posted, as I've only used it on projects involving small teams, but you should be able to sort that out by reading the WikiPedia page linked above. That said, it definitely meets the web-dev version control.
A vanilla installation of SVN isn't going to do this; it only does regular version control (commits, branches, etc.). There are plenty of web based svn interfaces, but all they do is give you a way to work with regular svn over the web. The document management features and workflow you require are going to come from some other document management system; I don't know of any that use svn as a back end.
I believe Mercurial provides a web-based interface as well.
For a simplistic, but working version control system made entirely in PHP, built on top of ASVCS, take a look at IntraVersion (http://webscripts.softpedia.com/script/Development-Scripts-js/IntraVersion-39805.html) Not much, but for those stuck like me with no server to host private projects on at the moment, it's a helper.
Have a look at knowledge tree. PHP, open source, with support/hosting available. I've used it in the past. It sucks less than other solutions.

Easiest way to implement an online order tracking database

I've been asked by a client to make an online tracking system for work we do for them (we will be typesetting a high volume of books for this client). Basically, it would be a database showing the books we are currently working on, with information on what stage of the project we are at, and estimated completion dates. The only people with access to this system would be us and employees of the client company.
I've worked in MySQL and PHP before; should I just go with what I know? This answer to a similar question suggests using Google Apps. I don't have any experience with Python, but happy to learn...
You're the only one using this therefore I see no reason to use Google Apps. I'm usually weary of people suggesting Google Apps, Amazon's s3, Microsoft Azure, etc. Also, you're going to be using a radically different data store. Unless you want an excuse to learn to do Google Apps and Python, I'd say go with MySQL+PHP and be done with it! In short, there aren't really any technical reasons for you to go with Google Apps here.
Sticking with what you know is always a good solution when dealing with delivering products to customers. No customer likes to be your guinea pig while you learn a new technology, although that's often how it's done. If you are comfortable with MySQL and PHP then stick with it if it satisfies your requirements, if it seems not to then look for libraries, frameworks and components written in PHP that might help you reach that goal. If you still have difficulties (unlikely given the scope of the project given) then ask questions here :) & search the web for solutions and patterns.
If all that fails and you can clearly solve your problem with another technology, then look at moving but make sure your customer is aware of how that's going to affect you timeframes.
When you've implemented this project and have some spare time, if there's a new direction you'd like to explore then use this project as your base and set to work without the stress of a deadline.
That's my 2p worth... good luck!
When developing a CRUD application such as this, you may be required to reinvent the wheel a little if starting from scratch. Many parts of your project are not unique to the project. E.g authentication, database access, form manipulation etc.
If getting things done is important to you it may be important to give your project a kick start and stop you wasting too much time.
Use a coding framework
Frameworks often have a lot of functionality ready for use straight out of the box.
Options may include Django, Ruby on Rails, Joomla, CakePHP, CodeIgniter.
Hack a tried and tested application
Open source projects are often quite easy to mould to your needs. Drupal and Joomla are CMS products which can be used in a wide variety of ways. If your book-tracking drupal module is any good, maybe you could go on to offer it as an open source plugin?
Use a currently available app in a new way
Your app seems to be tracking the status of items added to a database. How about using software designed for tracking other types of items. E.g. bug tracking software, project management to-do list software or customer relationship management software?
Well, as everyone has already said, if you already know PHP, that's got to be awfully tempting.
But it sounds simple enough that something like Django might save you a lot of time: its built-in admin interface could be used for the "update" side of the job, so all you'd need to template up is the "read" side, which is pretty easy.
I suggest you too look at Viravis.

Categories