Autor: Selene Melo Using composer
Objetivo: construir uma API Codeigniter para buscar uma proteína template para modelagem comparativa. Modelagem comparativa é quando se modela a estrutura 3d de uma proteína com base em uma estrutura parecida. Geralmente, precisamos de duas métricas: identidade (deve ser maior que 25%) e cobertura (deve ser maior que 50%).
Funcionamento: Recebe a sequência como entrada, compara ela contra todo o PDB usando blast (ex. de como fazer isso aqui: https://github.com/dcbmariano/arun/blob/main/4_blast/blast.py). Por fim, pega o melhor resultado e retorna na API.
- Download PHP;
- Download Composer or Artisan; //gerenciador de dependências
- Install frameworks (Laravel, CodeIgniter)
- GET: Retrieve resources
- POST: Create resources
- PUT: Update resources
- DELETE: Delete resources
- Framework: Laravel or CodeIgniter
- Requests: PHP, VScode, Postman, Wamp, GitBash
- Dependency manager: Artisan or Composer
$ composer create-project --prefer-dist laravel/laravel learning $ php artisan serve //start serverLaravel development server started pointed to: http://127.0.0.1:8000 Or, using CodeIgniter4:
$ composer create-project codeigniter4/appstarter $ cd meusite/spark
$ php spark serve CodeIgniter development server started pointed to: http://localhost:8080- O arquivo Spark é o gerenciador (script php) que gerencia o servidor web;
- env is a file that contains server-specific settings. Start by renaming it to .env
- Uncomment the line with CI_ENVIROMENT and change production to development
- A controller is a class that reads information from the request object and creates and return a reponse object, which could be a HTML page, JSON, XML, a file download, a redirect link or a 404 error. The controller runs whatever arbitrary logic your application needs to render the content of a page.
- The controller will become the center of every request to your web application
- We refer to a controller with $this
- We have made the controller. The next thing is to set routing rules. Routing associates a URI with a controller’s method.
- run nblast
- Inside of your site file, start server and go to the localhost page;
- If you would like to edit your page you will find it located at:
app/Views/welcome_message.php - The corresponding controller for this page can be found at:
app/Controllers/Home.php - PHP is a hypertext language used especially suited for web development and can be embbeded into HTML;
- PHP code is enclosed with special start and end processing instructions and executed on the server, generating a plain HTML that is then send to the client;
- Uses CSS and JavaScript for creating pages and edting styles;
- Primarily, we're going to focus on
- Model-View-Controller Architecture
- Routing basics
- Form validation
- Performing database queries
- Upload database (extensions must be .php) and add its credentials to the .env file located in the root of the project.
- DB_DATABASE = learning
- DB_USERNAME = root
- DB_PASSWORD = empty
- Run
$ php artisan make:model Article -m - Go to class CreateUsersTable() and add two lines:
$table->string('title')$table->string('body')
- Run
$ php artisan migrate(once migrated, the database are full) - Activate XAMPP control Panel and start MYSQL
- Go to app/Providers/AppServiceProvider and on:add:
public function boot():Schema::defaultStringLength(199) - Add the library:
use Illuminate\Support\Facades\Schema; - Acess: http://localhost/phpmyadmin/
- Run:
$ php artisan make:controller Country\CountryController - Go to: Routes/api.php/ and add
Route::get('country', [CountryController::class, 'country']); - Go to:
app\http\Controllers\CountryCountryController.phpand add:public function country(){ //here. we need a model.Let's create: - Run:
$ php artisan make:model Models\CountryModel - Go to:
ModelsCountryModel.phpand add the structure informations of the class _z_country. You can find the collumn informations on phpmyadminprotected $table = '_z_country'; protected $fillable = [ 'iso', 'name', 'dname', 'iso3', 'position', 'numcode', 'phonecode', 'created', 'register_by', 'modified', 'modified_by', 'record_deleted' ]; - Go back to
app\http\Controllers\CountryCountryController.php, add the libraryuse App\Models\CountryModel;and fill the new function that we've just created with:public function country(){ return response()->json(CountryModel::get(), 200); } - Start the server. Go to the localhost url and type: http://127.0.0.1:8000/api/country