Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ServerShell for PHP Built-in Server #713

Closed
wants to merge 14 commits into from
Closed

Added ServerShell for PHP Built-in Server #713

wants to merge 14 commits into from

Conversation

shin1x1
Copy link
Contributor

@shin1x1 shin1x1 commented Jul 11, 2012

Hi, I would propose adding new Shell Command.It is ServerShell.

ServerShell provides a httpd server for CakePHP application without other httpd server(Apache, nginx etc).

It is use PHP CLI build-in server.

Use case is below.

1. default (http://localhost/)

$ cd /path/to/app
$ ./Console/cake server

Welcome to CakePHP v2.2.0 Console
---------------------------------------------------------------
App : app
Path: /path/to/app/
---------------------------------------------------------------
ServerHost  : localhost
ListenPort  : 80
DocumentRoot: /path/to/app/webroot
---------------------------------------------------------------
[WARNING] Don't use this at the production enviroment
built-in server is running...

2. specify ListenPort (http://localhost:8000/)

$ ./Console/cake server -p 8000

Welcome to CakePHP v2.2.0 Console
---------------------------------------------------------------
App : app
Path: /path/to/app/
---------------------------------------------------------------
ServerHost  : localhost
ListenPort  : 8000
DocumentRoot: /path/to/app/webroot
---------------------------------------------------------------
[WARNING] Don't use this at the production enviroment
built-in server is running...

3. usage

$ ./Console/cake -h

Welcome to CakePHP v2.2.0 Console
---------------------------------------------------------------
App : app
Path: /Users/shin/sandbox/cakephp_shin1x1/app/
---------------------------------------------------------------
PHP Built-in Server for CakePHP

Usage:
cake server [-h] [-v] [-q] [-H] [-p] [-d]

Options:

--help, -h           Display this help.
--verbose, -v        Enable verbose output.
--quiet, -q          Enable quiet output.
--host, -H           ServerHost
--port, -p           ListenPort
--document_root, -d  DocumentRoot 

4. PHP 5.3 or lower

$ ./Console/cake server

Welcome to CakePHP v2.2.0 Console
---------------------------------------------------------------
App : app
Path: /path/to/app/
---------------------------------------------------------------
ServerHost  : localhost
ListenPort  : 80
DocumentRoot: /path/to/app/webroot
---------------------------------------------------------------
This command is available on PHP5.4 or above    

@burzum
Copy link
Contributor

burzum commented Jul 11, 2012

+1 but give it a better name like PhpWebserverShell and change the pull request to merge it into 2.3, not master.

@rchavik
Copy link
Member

rchavik commented Jul 11, 2012

Can we have shorter output, say:

    Welcome to CakePHP v2.2.0 Console
    ---------------------------------------------------------------
    App : app
    Path: /path/to/app/
    DocumentRoot: /path/to/app/webroot
    ---------------------------------------------------------------
    built-in server is running in http://somelocalsite.dev:80/

Also, [WARNING] Don't use this at the production enviroment is just noise imo, and should be documented in docs, not on each run.

const DEFAULT_PORT = 80;

/**
* server host
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not our indentation style for comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please use hard tabs rather then spaces.

Calling unset() on string indices fails fatally on 5.3.x and lower.

Fixes #3027
@@ -70,6 +70,11 @@
define('WWW_ROOT', dirname(__FILE__) . DS);
}

// for built-in server
if (php_sapi_name() == 'cli-server') {
$_SERVER['PHP_SELF'] = '/'.basename(__FILE__);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off here, Cake uses hard tabs.

@markstory
Copy link
Member

This change is also similar to #634

@shin1x1
Copy link
Contributor Author

shin1x1 commented Jul 12, 2012

Thanks for all the comments!
I will fix comment, indentation, tab, and typo:D

@burzum Hi, I change the pull request to 2.3 branch.
thank you new name! PhpWebserverShell is a good name.

but I will enter many characters.

$ ./Console/cake php_web_server

ServerShell is shorter.

$ ./Console/cake server

@rchavik good idea! I try to shorter output message.

@burzum
Copy link
Contributor

burzum commented Jul 12, 2012

@shin1x1 I clearly prefer to type a few characters more in favor for a better variable, class or shell name than ending up with non specific and generic names. To be honest, at least for me, and I do not think for any person who's programming for some time it really doesn't matter if you type 6 or 12 chars.

@markstory
Copy link
Member

I'd rather have the shorter name personally. php_web_server is a bit redundant, what other kind of server would you be starting other than a php + web server?

@rchavik
Copy link
Member

rchavik commented Jul 13, 2012

how about http_server ?

also, is it possible to squash these commits in a logical chunks?

@rchavik
Copy link
Member

rchavik commented Jul 13, 2012

nevermind about the squash, i just saw your #714. nice.

@rchavik rchavik closed this Jul 13, 2012
@shin1x1
Copy link
Contributor Author

shin1x1 commented Jul 14, 2012

@burzum I think that variable, class name should be a specific, too. I type a few chars with code completion(Vim, Emacs, Eclipse). But shell name is need to enter full chars. so, I like short name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants