Letractively / phpdays

Automatically exported from code.google.com/p/phpdays
0 stars 0 forks source link

Create application generator #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
THAT SHOULD BE ADDED

Create application generator to run from command line and from web browser.

New empty application located in "/apps/new". Need to use it.

Tasks:
 * generate new empty application
 * change exists application (add, edit, delete controllers and their actions)
 * check application on errors

If controller action exists - not overwrite it. If not esists - create new
empty action.

See also: site generators in Zend Framework, Yii framework, CakePHP

Original issue reported on code.google.com by anton.danilchenko on 22 Oct 2009 at 1:11

GoogleCodeExporter commented 8 years ago

Original comment by anton.danilchenko on 23 Oct 2009 at 5:08

GoogleCodeExporter commented 8 years ago
Generator files located into "generator" directory.

Please, help improve and test this.

Original comment by anton.danilchenko on 14 Nov 2009 at 3:26

GoogleCodeExporter commented 8 years ago
Started looking into the requirements

Original comment by 2aswathy@gmail.com on 24 Nov 2009 at 9:07

GoogleCodeExporter commented 8 years ago

Original comment by 2aswathy@gmail.com on 24 Nov 2009 at 10:29

GoogleCodeExporter commented 8 years ago
Added the code for creating a new project in webroot (copied the contents of 
apps/new to this new project). Functionality is enabled for command line tool 
(cli.php) only. Included the project generation as just another option along 
with 
controller actions. Not sure if this is the expected code structure,please 
clarify.

Attaching the patch.

Original comment by 2aswathy@gmail.com on 9 Dec 2009 at 2:08

Attachments:

GoogleCodeExporter commented 8 years ago
Implemented below mentioned changes:

1. Describe full options of all commands(Just made a small change in syntax 
description)
2. Replacement of $sCommand, $sType to $command & $type respectively
3. All variables to be placed inside {...}
4. Rename create(proj_name) to createProject(proj_name)
5. For case 'create' in cli.php remove the if condition there by removing the 
else 
code that is never executed in case of exceptions. Fail! message added to 
Exception 
itself.

Attaching the patch for review.

Original comment by 2aswathy@gmail.com on 10 Dec 2009 at 9:18

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thank you for changes!

Open attached diff file and see on my comments.

1. line 10: replace "controller_name:" to "controller_name" (without ":")

2. old syntax "$sCommandLine", and new syntax "$commandLine". Please, use new 
syntax
whole the system

3. line 25: use { and } in if conditio

4. line 26: move "break;" left to 4 spaces

5. line 59: delete empty line before method name

6. use "$proj_root = realpath" instead of "$proj_root=realpath" (add spaces 
before
and after operation)

7. line 64 (also 71): replace
"Project {$proj_name} already exists"
to
"Project '{$proj_name}' already exists"

8. linhe 67: delete 4 spacec before

9. line 71: delete this line and use it in file cli.php

10. line 99: replace
if( ($type=='content') ) {
to
if($type=='content') {

Please, apply this changes and attach new diff. I review you new diff.

Original comment by anton.danilchenko on 11 Dec 2009 at 10:35

GoogleCodeExporter commented 8 years ago
Applied the suggested changes. Please review the attached diff.

Original comment by 2aswathy@gmail.com on 11 Dec 2009 at 6:15

Attachments:

GoogleCodeExporter commented 8 years ago
Right. Apply the path.

Please, take a time and describe all available commands of generator like this:
new projectName - create new project
add controllerName action1 action2 ... - create new controller OR add actions to
existing controller
....

Please, describe all available commands and add to comment. We together correct 
this
commands. This need us for create documentation for end user and also for us.

Thanks!

Original comment by danilche...@gmail.com on 12 Dec 2009 at 10:30

GoogleCodeExporter commented 8 years ago
Referring to below comment 

General Comment:
Надо бы поправить
It is necessary to correct

Line-by-line comments:

File: /trunk/lib/Days/Tool/AppGenerator.php (r395)
===============================================================================

Line 60:         $source_dir = $proj_root.'/phpDays/apps/new';
-------------------------------------------------------------------------------
$proj_root - слишком далеко выходит по уровню, от 
этого привязка к имени папки с 
фреймворком 'phpDays', у меня, например, она по 
другому называется
$proj_root - too far out on the level of this binding to the folder with the 
frameworks 'phpDays'

Thanks for comment Alexander. Now i have prepared a new patch which solves the 
mentioned issue. Hope you could review that.

Original comment by 2aswathy@gmail.com on 13 Dec 2009 at 5:56

Attachments:

GoogleCodeExporter commented 8 years ago

Regarding the Documentation details you were asking in Comment#10:

Project Level Commands :

1.To Create new Project
new Projectname 
2.To Remove a Project
remove ProjectName

Controller Level Commands :
(Type of Controllers : site,content,block,form,frame. All removed elements are 
backed up in backup folder of phpDays framework ie phpDays/backup)

1. To create new controller (always create default action 'index') or add 
action to 
existing controller 
add controllerName action1 action2 

2. To replace selected actions in controller to new empty action (of course 
after 
backup).
replace controllerName action1 action2

3. To delete actions in a controller
Del ControllerName action1 action2

I think the above mentioned details could be included in the documentation. But 
while checking the code to add controllers and actions, what i understood was 
that 
the following folder is required.

phpDays/lib/Tool/site

I think it is yet to be created. If that is true, controller commands will not 
work 
for time being. Please correct me if my understanding is wrong. 

So i think the ToDo list for this task  will be

1. Replace and Delete operations seems to need the code for backup to be filled 
in 
AppGenerator.php. Hence to fill it up.

2. Write code to remove the Project after backup.

3. Please suggest what to do with add command for controllers and action.

4. For new command (for Project) I think we could include below mentioned steps 
from 
Installation Documentation into code

FOR LOCAL SERVER create .htaccess file in /var/www with content mentioned
FOR LOCAL SERVER create index.php file in /var/www with content mentioned
open /var/www/myblog/public/index.php and change path to phpDays framework and 
you 
application dir 
require_once '/var/lib/Days/Engine.php';
Days_Engine::run('/var/www/myblog/app/', 'development');

Please give your suggestions.

Original comment by 2aswathy@gmail.com on 14 Dec 2009 at 8:07

GoogleCodeExporter commented 8 years ago
I have standartize all connamnd to simple for understand it.

One of case:
 - ptoject new - generate project in current directory
 - project clear - recreate project (backup all data and create new empty project)
 - controller new controllerName action1 action2 - create controller with specified
actions (will be automatically created "indexAction")
 - controller del controllerName action1 action2 - delete specified actions in controller
 - controller clear controllerName action1 action2 - controller will be backup copy
and deleted specified actions in controller and created empty specified actions
 - model [new|del|clear] modelName - similar with "controller" command
 - view [new|del|clear] folder/file1 folder/file2 - work with html templates (maybe
this templates created automatically on create controllers - this save a time)

For more details see
http://www.symfony-project.org/getting-started/1_2/en/05-Project-Setup

All data for new project site we found in folder "/apps/new/" - this always 
fresh
empty project structure.

For "create" and "delete" actions into class we need use Zend Framework 
component
Zend_CodeGenerator (see 
http://framework.zend.com/manual/en/zend.codegenerator.html).
This help us implement this task.

Main task of AppGenerator - help automatically create project and save time. 
Now I
copy code from "apps/new" directory, change database connection settings, change
folders permissions (this need also automatically apply). This all need push to
AppGenerator. Maybe we need to use Zend Framework generator and save our time.
Please, see on this already existing components and use it if this need.

Thanks!

Original comment by anton.danilchenko on 18 Dec 2009 at 9:49

GoogleCodeExporter commented 8 years ago
Please review AppGenerator3.diff. It needs to be checked into Repository for
AppGenerator to work properly in Linux OS.

Original comment by aswathy9918@gmail.com on 22 Dec 2009 at 11:36

GoogleCodeExporter commented 8 years ago
Hi!

Please, see on this article 
http://codeigniter.com/user_guide/general/scaffolding.html

This maybe help you.

Original comment by anton.danilchenko on 2 Jan 2010 at 1:54

GoogleCodeExporter commented 8 years ago
Please, see also
http://www.joeyrivera.com/2009/automate-model-creation-with-zend_codegenerator_p
hp_class/
(Automate Db Model Creation with Zend_CodeGenerator_Php_Class)

Original comment by anton.danilchenko on 3 Jan 2010 at 10:29

GoogleCodeExporter commented 8 years ago
If Windows had a command line unzip it would be so ease to do the "copy, set
permissions" part.
Ruby on Rails uses rake (Ruby make) to do model updates (and a lot more.) There 
are
at least two make-like tools available for PHP: Phing http://phing.info/ and 
Pake
http://wiki.github.com/indeyets/pake .
Make can also be used to generate config classes from configuration files when 
they
are changed, that could solve the problem with caching configuration, 
reading/parsing
configs on the fly. 

Original comment by letl...@gmail.com on 4 Jan 2010 at 8:04

GoogleCodeExporter commented 8 years ago
Added one more functionality for command line tool. It is to remove a project 
using the tool, after backup. Please find the patch attached.

Hope you will review the patch and give suggestions to improve. In case 
everything is fine i will check in the patch.

Original comment by 2aswathy@gmail.com on 8 Jul 2010 at 8:25

Attachments: