A partir  do PHP 5.4 foi adicionado um servidor interno, para testar nossas aplicações em php sem a necessidade de utilizar um servidor como Apache. Recomendo que utilizem este recurso em suas aplicações e evitem o famoso localhost/nomedoprojeto, para evitar conflitos em base url, compartilhamento de sessão, cookies e etc. Para utilizar o recurso é muito simples siga o passo a passo:

Passo 1:

Primeiramente tenha o php configurando nas variáveis de ambiente, isso é muito simples, basta colocar o diretório do php no path.

Passo 2:

Crie uma pasta chamada public_html no diretório c://public_html, lembrando que você pode escolher o diretório de sua preferencia, isso é apenas uma dica para facilitar o desenvolvimento.

Passo 3:

Abra o cmd (prompt de comando) e digite os seguintes comandos:

 cd c://
 cd public_html
 php -S 127.0.0.1:8888

Pronto, agora é testar suas aplicações.

Mas o que significa esses comandos?

php -S <servidor>:<porta> <parâmetros>

-S – indica que você quer levantar um server
127.0.0.1 – indica o ip que você ira usar, pode ser localhost, ou qualquer outro nome que responde por um ip
:8888 – é o número da porta na qual você ira levantar sua aplicação

Não esqueçam de ler a documentação http://www.php.net/manual/en/features.commandline.webserver.php

Espero que tenham gostado ;)


Samuelson
Samuelson

Apenas um desenvolvedor que resolveu compartilhar o que aprendeu, procuro passar a realidade do desenvolvimento de software com exemplos práticos e sem enrolação. Trabalho com desenvolvimento de SREP (Sistemas de Registo Eletrônico de Ponto) e integração de leitores biométricos de acordo com os padrões da portaria 373/2011.

    25 replies to "Utilizando o servidor embutido do PHP"

    • hagamenon

      Fala samu!!!
      Cara ótima iniciativa mano!!!
      É raro hoje em dia pessoas assim, e é disso que estamos precisando!!!
      Estou terminando analise e desenvolvimento de sistemas pela estacio (EAD) e quando terminar também irei dar minha contribuição para a humanidade, especialmente aqui no Brasil, que tanto necessita de esclarecimentos e pessoas com disposição e paciência para ensinar, não visando somente lucro e nem pensando só em si, mas contribuindo.
      Mas uma vez obrigado mesmo, seus videos tem me ajudado muito, por favor continue e se eu também puder fazer algo só me dizer, vlw !!!

    • Johnatan

      Fácil e Prático, valeu!

    • gamefly free trial

      I think everything said was actually very reasonable. However,
      think about this, suppose you composed a catchier title?
      I am not saying your content is not solid.,
      but what if you added a title that makes people want more?
      I mean Utilizando o servidor embutido do PHP – Descompila is kinda vanilla.
      You should look at Yahoo’s home page and note how
      they write post headlines to get viewers to open the links.
      You might add a video or a related picture or two to
      grab people excited about everything’ve written. In my
      opinion, it might bring your posts a little bit more interesting.

    • Howdy! Do you know if they make any plugins to protect
      against hackers? I’m kinda paranoid about losing everything I’ve
      worked hard on. Any tips?

    • gamefly free trial

      Hello there! Would you mind if I share your blog with my
      zynga group? There’s a lot of people that I think would really enjoy
      your content. Please let me know. Thank you

    • gamefly free trial

      It’s very simple to find out any matter on web as compared to
      books, as I found this paragraph at this web page.

    • I always used to study post in news papers but now
      as I am a user of internet therefore from now I am using
      net for articles, thanks to web.

    • gamefly free trial

      Greetings from Carolina! I’m bored at work so I decided to browse your blog on my
      iphone during lunch break. I love the info you
      present here and can’t wait to take a look when I get home.
      I’m shocked at how quick your blog loaded on my phone ..
      I’m not even using WIFI, just 3G .. Anyhow, amazing site!

    • gamefly free trial

      Amazing issues here. I’m very satisfied to see your article.
      Thanks so much and I am looking forward to contact you.

      Will you please drop me a e-mail?

    • Matsiva

      Real Finasteride I Need Viagra Overnight Delivery Canada Ajanta Pharma Limited Kamagra canadian pharmacy cialis 20mg Does Cialis Work Better With Aspirin Viagra Blogs Best Online Propecia Abgelaufen

    • gamefly free trial

      When someone writes an piece of writing he/she
      keeps the image of a user in his/her brain that how a user can know it.
      Therefore that’s why this post is perfect. Thanks!

    • gamefly free trial

      Do you have a spam issue on this website; I also am a blogger,
      and I was wondering your situation; many of us have created some nice practices and we are looking to trade techniques with others, be sure to
      shoot me an e-mail if interested.

    • gamefly free trial

      I got this site from my friend who told me concerning this web page and at
      the moment this time I am browsing this web site and reading very
      informative articles or reviews here.

    • gamefly free trial

      I think this is among the most vital information for
      me. And i’m glad reading your article. But should remark on few general things, The web site style is ideal, the articles is
      really great : D. Good job, cheers

    • gamefly free trial

      Hello, its good article about media print, we all be aware of media is
      a wonderful source of information.

    • You really make it seem so easy with your presentation but I find this topic to be actually something which I think I would never understand.
      It seems too complicated and very broad for me. I am looking
      forward for your next post, I’ll try to get the
      hang of it!

    • There’s certainly a great deal to find out about this topic.
      I really like all of the points you made.

    • Hi there, You have done an incredible job. I will certainly
      digg it and personally recommend to my friends. I’m sure they’ll
      be benefited from this site.

    • Hello! This is kind of off topic but I need some help
      from an established blog. Is it hard to set up your
      own blog? I’m not very techincal but I can figure things
      out pretty fast. I’m thinking about making my own but I’m not sure
      where to begin. Do you have any ideas or suggestions? With
      thanks

    • ปั้มไลค์

      Like!! Great article post.Really thank you! Really Cool.

    • quest bars cheap

      I read this piece of writing fully on the topic of the comparison of
      hottest and earlier technologies, it’s amazing article.

    • quest bars cheap

      Hi i am kavin, its my first time to commenting anyplace, when i
      read this article i thought i could also create comment due to this brilliant post.

    • quest bars

      At this time I am going to do my breakfast, when having my breakfast coming over again to read more news.

Leave a Reply

Your email address will not be published.