> ## Documentation Index
> Fetch the complete documentation index at: https://jancontrerasdev-gestor-contrasenas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install and set up the Password Manager API on your server

**1. System Requirements**

Ensure your system meets the following requirements:

* PHP >= 8.0.2
* Composer
* MySQL or PostgreSQL database
* Web server (Apache, Nginx, etc.)

**2. Clone or Download the Repository**

Get the source code for the Password Manager API:

```bash theme={null}
git clone https://github.com/JanContrerasDev/gestor-contrasenas.git
cd gestor-contrasenas
```

**3. Install Dependencies**

Install all required PHP packages using Composer:

```bash theme={null}
composer install
```

This will install:

* Laravel Framework 9.19+
* Laravel Sanctum 3.0+ (for API authentication)
* Guzzle HTTP client
* Development dependencies (PHPUnit, Laravel Pint, etc.)

**4. Environment Configuration**

Copy the example environment file and generate an application key:

```bash theme={null}
cp .env.example .env
php artisan key:generate
```

> [!NOTE]
>
> The `key:generate` command will set the `APP_KEY` value in your `.env` file. This key is used for encrypting data and must be set before using the application.

**5. Configure Database**

Edit your `.env` file and set your database credentials:

```bash theme={null}
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user
DB_PASSWORD=your_database_password
```

Create the database if it doesn't exist:

```bash theme={null}
mysql -u root -p -e "CREATE DATABASE your_database_name;"
```

**6. Run Database Migrations and Create Passwords Table**

Execute the migrations to create the required database tables:

```bash theme={null}
php artisan migrate
```

This will create the following tables:

* `users` - User accounts
* `password_resets` - Password reset tokens
* `failed_jobs` - Failed queue jobs
* `personal_access_tokens` - Sanctum API tokens

> [!WARNING]
>
> The `passwords` table migration is not included in the repository. You need to create it manually or generate a migration for it.

**Create the passwords table:**

You can create the table manually using this SQL:

```sql theme={null}
CREATE TABLE passwords (
    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    password VARCHAR(255) NOT NULL,
    sistema VARCHAR(255) NOT NULL,
    usuario VARCHAR(255) NOT NULL,
    status TINYINT DEFAULT 1,
    created_at TIMESTAMP NULL,
    updated_at TIMESTAMP NULL
);
```

Or generate a Laravel migration:

```bash theme={null}
php artisan make:migration create_passwords_table
```

Then add this code to the migration file:

```php theme={null}
public function up()
{
    Schema::create('passwords', function (Blueprint $table) {
        $table->id();
        $table->string('password');
        $table->string('sistema');
        $table->string('usuario');
        $table->tinyInteger('status')->default(1);
        $table->timestamps();
    });
}

public function down()
{
    Schema::dropIfExists('passwords');
}
```

Run the migration:

```bash theme={null}
php artisan migrate
```

**7. Start the Development Server**

Launch the Laravel development server:

```bash theme={null}
php artisan serve
```

The API will be available at `http://localhost:8000`

> [!NOTE]
>
> For production deployments, configure your web server (Apache/Nginx) to serve the application instead of using the development server.

**8. Verify Installation**

Test that the API is running by accessing:

```bash theme={null}
curl http://localhost:8000/api/listPassword
```

You should receive a JSON response (empty array or list of passwords depending on your data).

## Post-Installation

After completing the installation, you should:

1. **Configure authentication** - See the [Authentication](https://jancontrerasdev-gestor-contrasenas.mintlify.site/authentication.md) guide
2. **Set up environment variables** - See the [Configuration](https://jancontrerasdev-gestor-contrasenas.mintlify.site/configuration.md) guide
3. **Review security settings** - Ensure `APP_DEBUG=false` in production
4. **Configure caching** - Set up Redis or Memcached for better performance

## Troubleshooting

### Permission Issues

If you encounter permission errors, ensure the web server has write access to these directories:

```bash theme={null}
chmod -R 775 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache
```

### Database Connection Failed

Verify your database credentials in `.env` and ensure the database server is running:

```bash theme={null}
php artisan config:clear
php artisan cache:clear
```

### Composer Install Errors

If composer install fails, try updating Composer:

```bash theme={null}
composer self-update
composer update
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.