BeyondTube is a full-featured video sharing platform inspired by YouTube, built with PHP and Yii2. It allows users to upload, view, like, and comment on videos, manage channels, and interact with content in a modern, multi-tier web application.
- User registration, authentication, and channel management
- Video upload, playback, and thumbnail generation
- Like/dislike system with AJAX support
- Video view tracking
- Studio backend for managing videos
- Responsive frontend for a seamless user experience
- Database migrations and easy local setup
git clone https://github.com/MachineKe/beyondtube.git
cd beyondtubeMake sure you have Composer installed.
composer install-
Ensure your environment variables for the database connection are set (
DB_HOST,DB_NAME,DB_USER,DB_PASSWORD) before running migrations. -
Run the Yii2 migrations to create all required tables:
php yii migrateAlternatively, you can run migrations using your web browser. Simply use your frontend URL and visit the migrate.php route. For example:
frontendUrl/migrate.php
This will execute the migrations through a web interface, which can be useful if you do not have command-line access. Make sure your environment variables are set before using this method as well.
- For local development, you can use the built-in PHP server to run both the frontend and backend applications in separate terminals:
Frontend:
php yii serve --port=8080 --docroot=frontend/webAccess at: http://localhost:8080/
Backend:
php yii serve --port=8081 --docroot=backend/webAccess at: http://localhost:8081/
- Or configure Apache/Nginx to point the web root to
frontend/webandbackend/webfor the respective applications.
- Frontend: http://localhost:8080/ (if using
php yii serve) - Backend: Configure your web server to point to
backend/weband access via browser.
The application requires the following environment variables to be set (see the provided example.env file for examples):
SMTP_HOST- SMTP server hostnameSMTP_PORT- SMTP server port (e.g. 587)SMTP_USER- SMTP username (used by frontend config/controllers)SMTP_PASS- SMTP password (used by frontend config/controllers)SMTP_FROM_EMAIL- Default "from" email address for outgoing mailSMTP_FROM_NAME- Default "from" name for outgoing mail
DB_HOST- Database server hostnameDB_NAME- Database nameDB_USER- Database usernameDB_PASSWORD- Database password
FRONTEND_URL- The base URL for the frontend application (e.g.http://beyondtube.test). Used incommon/config/params.phpandbackend/config/params.phpto generate links and references to the frontend from the backend or shared code.BACKEND_URL- The base URL for the backend application (e.g.http://studio.beyondtube.test). Used incommon/config/params.phpto generate links and references to the backend from the frontend or shared code.
These variables allow you to configure how the frontend and backend reference each other, which is especially useful when running in different environments (local, staging, production) or when using custom domains. Set these in your .env file to match your local or production setup.
All sensitive credentials and URLs should be set in your .env file in the project root. The application will read these variables at runtime for secure configuration.
For a more realistic development environment, you can set up Apache virtual hosts to serve the frontend and backend as separate subdomains or paths.
Add the following to your Apache httpd-vhosts.conf (adjust paths as needed):
<VirtualHost *:80>
ServerName beyondtube.test
DocumentRoot "<path-to-project>/frontend/web"
<Directory "<path-to-project>/frontend/web">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName studio.beyondtube.test
DocumentRoot "<path-to-project>/backend/web"
<Directory "<path-to-project>/backend/web">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>Add these lines to your system's hosts file:
127.0.0.1 beyondtube.test
127.0.0.1 studio.beyondtube.test
- On Windows:
C:\Windows\System32\drivers\etc\hosts - On Linux/Mac:
/etc/hosts
After updating the configuration and hosts file, restart Apache. You can now access:
- Frontend: http://beyondtube.test/
- Backend: http://studio.beyondtube.test/
common
config/ contains shared configurations
mail/ contains view files for e-mails
models/ contains model classes used in both backend and frontend
tests/ contains tests for common classes
console
config/ contains console configurations
controllers/ contains console controllers (commands)
migrations/ contains database migrations
models/ contains console-specific model classes
runtime/ contains files generated during runtime
backend
assets/ contains application assets such as JavaScript and CSS
config/ contains backend configurations
controllers/ contains Web controller classes
models/ contains backend-specific model classes
runtime/ contains files generated during runtime
tests/ contains tests for backend application
views/ contains view files for the Web application
web/ contains the entry script and Web resources
frontend
assets/ contains application assets such as JavaScript and CSS
config/ contains frontend configurations
controllers/ contains Web controller classes
models/ contains frontend-specific model classes
runtime/ contains files generated during runtime
tests/ contains tests for frontend application
views/ contains view files for the Web application
web/ contains the entry script and Web resources
widgets/ contains frontend widgets
vendor/ contains dependent 3rd-party packages
environments/ contains environment-based overrides