My first php project

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Example project to be used in my talk at php[world] 2017

License

ConquerorSoft/my_first_project

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

This is my very first project I created at php[world]. I learned that I have to create a README file to provide a description of my project so it can be used by other projects or persons.

The steps to create «my first project»

1- create the my_first_project directory

cd ~ && mkdir -p phplibrary/my_first_project && cd phplibrary/my_first_project 

3- initialize a git repository

git add . git commit -m "First commit of my project" 

5- Assign a version to your project

git tag -a v0.1.0 -m "version 0.1.0" 

6- Create a repository in github or bitbucket 7- Connect your repository with github (or bitbucket)

git remote add origin https://github.com/ConquerorSoft/my_first_project.git git push -u origin master git push origin v0.1.0 

9- enter all the information asked by composer init

Package name (/) [gabriel/my_first_project]: conquerorsoft/my_first_project Description []: Project created with composer init Author [Christian Varela , n to skip]: Christian Varela Minimum Stability []: Package Type (e.g. library, project, metapackage, composer-plugin) []: project License []: MIT Define your dependencies. Would you like to define your dependencies (require) interactively [yes]? Search for a package: php Enter the version constraint to require (or leave blank to use the latest version): ^5.6 || ^7.0 Search for a package: Would you like to define your dev dependencies (require-dev) interactively [yes]? Search for a package: phpunit/phpunit Enter the version constraint to require (or leave blank to use the latest version): ^5.7 Search for a package: squizlabs/php_codesniffer Enter the version constraint to require (or leave blank to use the latest version): 3.* Search for a package: < "name": "conquerorsoft/my_first_project", "description": "Project created with composer init", "type": "project", "require": < "php": "^5.6 || ^7.0" >, "require-dev": < "phpunit/phpunit": "^5.7", "squizlabs/php_codesniffer": "3.*" >, "license": "MIT", "authors": [ < "name": "Christian Varela", "email": "cvarela@conquerorsoft.com" >] > Do you confirm generation [yes]? Would you like the vendor directory added to your .gitignore [yes]? 

10- composer.json file is created, edit it to include your library

 < "name": "conquerorsoft/my_first_project", "description": "Project created with composer init", "type": "project", "repositories": [ < "type": "vcs", "url": "/Users/gabriel/phplibrary/my_first_library" >], "require": < "php": "^5.6 || ^7.0", "conquerorsoft/my_first_library": "^0.1" >, "require-dev": < "phpunit/phpunit": "^5.7", "squizlabs/php_codesniffer": "3.*" >, "license": "MIT", "authors": [ < "name": "Christian Varela", "email": "cvarela@conquerorsoft.com" >] > 
git add . git commit -m "Composer init" git tag -a v0.1.1 -m "version 0.1.1" git push -u origin master git push origin v0.1.1 

13- create a Changelog file ( this format is recommended: Keep a Changelog )

git add . git commit -m "Changelog file added" git tag -a v0.1.2 -m "version 0.1.2" git push -u origin master git push origin v0.1.2 

15- Create structure for starting the development

16- Edit the composer.json file to be this way now:

 < "name": "conquerorsoft/my_first_project", "description": "Project created with composer init", "type": "project", "keywords": [ "conquerorsoft", "my_first_project", "tutorial", "phpworld 2017", "workshop" ], "homepage": "http://www.conquerorsoft.com/my_first_project", "repositories": [ < "type": "vcs", "url": "/Users/gabriel/phplibrary/my_first_library" >], "require": < "php": "^5.6 || ^7.0", "conquerorsoft/my_first_library": "^0.1" >, "require-dev": < "phpunit/phpunit": "^5.7", "squizlabs/php_codesniffer": "3.*" >, "license": "MIT", "authors": [ < "name": "Christian Varela", "email": "cvarela@conquerorsoft.com", "homepage": "http://www.conquerorsoft.com/ChristianVarela", "role": "Developer" >], "minimum-stability": "stable", "scripts": < "test": "phpunit", "check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests", "fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests" >> 

17- Create file phpunit.xml

18- add build to .gitignore

echo "build/" >> .gitignore git add . git commit -m "Preparation for development" git tag -a v0.1.3 -m "version 0.1.3" git push -u origin master git push origin v0.1.3 

21- Add a LICENSE.md file (for this example we chose MIT)

22- Create tests/FirstProjectClassTest.php

vim tests/FirstProjectClassTest.php 

23- Create src/FirstProjectClass.php

vim src/FirstProjectClass.php 

24- Add autoload section to composer.json

25- Rum composer dump-autoload

git add . git commit -m "Classes from project calling my library" git tag -a v0.1.4 -m "version 0.1.4" git push -u origin master git push origin v0.1.4 

27- add repository to Travis and create travis configuration file

git add . git commit -m "Travis CI integration" git tag -a v0.1.5 -m "version 0.1.5" git push -u origin master git push origin v0.1.5 

29- Change composer.json to use github repository instead of file system local folder

vim composer.json "repositories": [ < "type": "vcs", "url": "https://github.com/ConquerorSoft/my_first_library" >], 
git add . git commit -m "VCS reference changed for my_first_library in composer.json" git tag -a v0.1.6 -m "version 0.1.6" git push -u origin master git push origin v0.1.6 

32- Remove references for repositories in composer.json since now the library is on packagist.org 33- Run composer update

composer clearcache composer update 
git add . git commit -m "my_first_library is now taken from packagist" git tag -a v0.1.7 -m "version 0.1.7" git push -u origin master git push origin v0.1.7 

35- Link scrutinizer-ci account with github and create .scrutinizer.yml file

git add . git commit -m "Scrutinizer support added" git tag -a v0.1.8 -m "version 0.1.8" git push -u origin master git push origin v0.1.8 

37- change composer.json to require version ^1.0.0 for my_first_library

"conquerorsoft/my_first_library": "^1.0" 
git add . git commit -m "Using version ^1.0 from my_first_library" git tag -a v0.1.9 -m "version 0.1.9" git push -u origin master git push origin v0.1.9 

40- Create contributing files

vim CONTRIBUTING.md vim CODE_OF_CONDUCT.md 

43- Add more sections to README file

git add . git commit -m "Improvements to README" git tag -a v0.1.10 -m "version 0.1.10" git push -u origin master git push origin v0.1.10 

45- submit the package to packagist.org using the github repository 46- Make the package to be autoupdated in packagist on push

  • Go to your GitHub repository
  • Click the «Settings» button
  • Click «Integrations & services»
  • Add a «Packagist» service, and configure it with your API token, plus your Packagist username
  • Check the «Active» box and submit the form

47- Add last version in packagist badge to README.md file

git add . git commit -m "Instructions to use packagist.org in README" git tag -a v0.1.11 -m "version 0.1.11" git push -u origin master git push origin v0.1.11 

49- Create a gh-pages branch

git checkout -b gh-pages git push -u origin gh-pages git checkout master 

50- Go to github settings for your repository 51- Choose a theme in GitHub Pages section 52- Your project page is ready now: https://conquerorsoft.github.io/my_first_project/ 53- commit to git and increase version

git add . git commit -m "Documentation instructions for the project" git tag -a v1.0.0 -m "version 1.0.0" git push -u origin master git push origin v1.0.0 
composer create-project conquerorsoft/my_first_project
cd src php -a Interactive shell php > include ('../vendor/autoload.php'); php > $fpc=new conquerorsoft\my_first_project\FirstProjectClass(); php > echo $fpc->encoding("Test string"); The string 'Test string' is encoded as '2n12 120rwp' php > echo $fpc->decoding("2n12 120rwp"); The string '2n12 120rwp' is decoded as 'test string' php > exit 

Please see CHANGELOG for more information on what has changed recently.

Источник

Быстрое учебное руководство по PHP IDE NetBeans

В этом документе приведены общие рекомендации по подготовке среды для разработки PHP, настройки проекта PHP и разработки и запуска первого приложения PHP в IDE NetBeans для PHP.

netbeans stamp 80 74 73

Для работы с этим учебным курсом требуется следующее программное обеспечение и ресурсы.

Систему PHP, веб-сервер и базу данных можно установить отдельно или использовать пакеты AMP (*A*pache, *M*ySQL, *P*HP).

Установка и настройка

Следующие документы содержат описание одного или двух способов установки веб-стека PHP в операционной системе. Эти указания не являются исчерпывающими. Веб-стек состоит из программного обеспечения других производителей, среда может различаться, а разработчик может предпочесть другой пакет AMP или другой способ установки PHP. Приведенные указания следует дополнить собственными наблюдениями.

Настройка проекта PHP в IDE NetBeans для PHP

Дополнительные свдения по установке и запуске IDE NetBeans см. в документации по установке.

Для начала разработки PHP в IDE NetBeans для PHP сначала необходимо создать проект. Проект содержит информацию о размещении файлов проекта и способе запуска и отладки приложения (конфигурация запуска ).

  1. Запустите среду IDE, перейдите в окно «Проекты» и выберите команду «Файл > Создать проект». Откроется панель «Выберите проект».
  2. В списке категорий выберите PHP.
  3. В области «Проекты» выберите «Приложение PHP» и нажмите кнопку «Далее». Откроется панель «Новый проект PHP > Имя и местоположение».

new project name location

Figure 2. Панель ‘Имя и местоположение’ мастера создания проектов PHP с местоположением исходной папки как корня документации XAmpp.

  1. В текстовом поле наименования проекта введите NewPHPProject .
  2. В поле исходной папки перейдите к корню документов PHP и создайте подпапку NewPHPProject . Корень документов – это папка, в которой веб-сервер ищет файлы для открытия в браузере. Корневой узел документов указан в файле настройки веб-сервера. Например, в Xampp корнем документов является папка XAMPP_HOME/htdocs.
  3. В остальных полях оставьте значения по умолчанию. Нажмите кнопку «Далее». Откроется окно «Настройки выполнения».

new project run config

  1. В раскрывающемся списке «Выполнить как» выберите «Локальный веб-сайт». Начнется выполнение проекта на локальном сервере Apache. Проект можно также выполнить удаленно через FTP или запустить его из командной строки.
  2. Оставьте поле «URL-адрес проекта» без изменений.
  3. Нажмите кнопку «Завершить». Средой IDE будет создан проект.

Выполнение своего первого проекта PHP

  1. Запустите среду IDE, выберите команду «Файл > Открыть проект». Откроется диалоговое окно «Открыть проект».
  2. Выберите NewPHPProject и нажмите кнопку «Открыть проект». В окне проекта появится дерево проекта NewPHPProject, а в редакторе и в окне навигатора откроется файл index.php .

getting started open new project

 echo "Hello, world! This is my first PHP project!";
  1. Для выполнения этого проекта поместите курсор на узел NewPHPProject и в контекстном меню выберите команду «Выполнить». На рисунке ниже показано, что должно отобразиться в окне браузера.

getting started browser hello world

Поздравляем! Программа работает!

Использование серверов баз данных с IDE NetBeans для PHP

Можно использовать различные серверы баз данных с IDE NetBeans для PHP, хотя наиболее популярным является сервер MySQL. Загрузку можно осуществить отсюда. Примечание. Рекомендуемая версия продукта: MySQL Server 5.0. Дополнительные материалы:

Что дальше?

В это же время для поиска информации, связанной с типом разрабатываемых приложений, используйте учебные карты IDE NetBeans для этого типа приложения. Каждая учебная карта содержит ряд учебных курсов и руководств различных уровней сложности. Доступны следующие учебные карты:

Для отправки комментариев и предложений, получения поддержки и новостей о последних разработках, связанных с PHP IDE NetBeans присоединяйтесь к списку рассылки users@php.netbeans.org.

Источник

Читайте также:  Java hibernate postgresql gradle
Оцените статью