Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added a feature to serve the app using the terminal command 'php codeholic serve' #24

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

Closed
aditya-zanjad wants to merge 34 commits into thecodeholic:master from aditya-zanjad:implement_php_codeholic_serve
Closed

Added a feature to serve the app using the terminal command 'php codeholic serve' #24

aditya-zanjad wants to merge 34 commits into thecodeholic:master from aditya-zanjad:implement_php_codeholic_serve

Conversation

Copy link

@aditya-zanjad aditya-zanjad commented Apr 27, 2022
edited
Loading

Added an alternate way to serve the app using the terminal command php codeholic serve

From the root directory, where README.md file is located, you can now run the following terminal command to serve the app.

php codeholic serve

FIRST NOTE
The file codeholic.php has been renamed to just codeholic.
This way we can just run php codeholic serve instead of php codeholic.php serve.


SECOND NOTE
In the fourth commit, added the ability to specify port number & host url for the command php codeholic serve.
Now, we can specify parameters '--port' & '--host'. If the user does not provide any value for --port argument, then its default value will always be 8080.

Some examples below:

php codeholic serve --host=localhost --port=8081
php codeholic serve --host=127.0.0.1
php codeholic serve --port=5000

THIRD NOTE
In the seventh commit, added the option to specify the parameter --max-port to decide the limit upto which to try to run the PHP's built-in server on before showing a failure message. The value of the parameter --max-port should always be equal to or greater than the value of the parameter --port.

If the user does not provide any value for --port argument, then its default value will always be 8080.

Also, there is a hard limit set on the value of --max-port. This means, the value of --max-port should never be greater than the addition of value of --port plus 100. This is done to make sure that the for loop in the program will not like run forever.

Some valid examples below:

php codeholic serve --max-port=8180
php codeholic serve --port=9000 --max-port=9100

Some invalid examples below:

php codeholic serve --max-port=9000
php codeholic serve --port=9000 --max-port=10000

@aditya-zanjad aditya-zanjad changed the title (削除) Serve app using 'php codeholic serve' command... An alternative way to run the app... (削除ここまで) (追記) Added a feature to serve app using 'php codeholic serve' command... An alternative way to run the app... (追記ここまで) Apr 27, 2022
@aditya-zanjad aditya-zanjad changed the title (削除) Added a feature to serve app using 'php codeholic serve' command... An alternative way to run the app... (削除ここまで) (追記) Added a feature to serve the app using the terminal command 'php codeholic serve' (追記ここまで) Apr 28, 2022
Copy link
Owner

That is awesome @aditya-zanjad. Thank you for it.
I will test it and as far as there are no issue I will merge this.

aditya-zanjad reacted with thumbs up emoji

Copy link
Owner

@thecodeholic thecodeholic left a comment

Choose a reason for hiding this comment

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

This feature is great. Thanks for contributing.

@@ -0,0 +1,2 @@
{
Copy link
Owner

@thecodeholic thecodeholic Sep 25, 2022

Choose a reason for hiding this comment

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

I think we should completely ignore .vscode folder.

codeholic Outdated
}

// If default port is free, run PHP's built-in server on it
if (exec(`php -S $host:$port -t $pathToMainIndex`)) {
Copy link
Owner

@thecodeholic thecodeholic Sep 25, 2022

Choose a reason for hiding this comment

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

When the default port is occupied and this code is executed. Code throws an error and does not try to allocate next port.

Copy link
Author

@aditya-zanjad aditya-zanjad Sep 26, 2022

Choose a reason for hiding this comment

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

@thecodeholic Thanks for notifying me about these issues. I'll try to fix them ASAP.

Copy link
Author

@thecodeholic Thank you for the feedback. The suggested changes are now implemented. Thank you.

Copy link
Owner

@aditya-zanjad Thank you for this.
I will review it and test and then merge if everything looks good.
I love the feature. Well Done.

aditya-zanjad reacted with thumbs up emoji

gg-aditya and others added 10 commits September 27, 2022 18:42
@aditya-zanjad aditya-zanjad closed this by deleting the head repository Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@thecodeholic thecodeholic Awaiting requested review from thecodeholic

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /