{"id":16326803,"url":"https://github.com/jr-cologne/login-script","last_synced_at":"2025-04-04T11:02:06.018Z","repository":{"id":57002115,"uuid":"71133161","full_name":"jr-cologne/login-script","owner":"jr-cologne","description":"A simple object-oriented and database-based login script with PHP.","archived":false,"fork":false,"pushed_at":"2019-08-20T13:16:05.000Z","size":162,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T21:13:28.500Z","etag":null,"topics":["database-based","object-oriented","oop","php"],"latest_commit_sha":null,"homepage":"https://login-script.herokuapp.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jr-cologne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-17T11:54:49.000Z","updated_at":"2019-08-20T13:12:43.000Z","dependencies_parsed_at":"2022-08-21T14:10:34.319Z","dependency_job_id":null,"html_url":"https://github.com/jr-cologne/login-script","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr-cologne%2Flogin-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr-cologne%2Flogin-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr-cologne%2Flogin-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr-cologne%2Flogin-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jr-cologne","download_url":"https://codeload.github.com/jr-cologne/login-script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166159,"owners_count":20894653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-based","object-oriented","oop","php"],"created_at":"2024-10-10T23:09:36.867Z","updated_at":"2025-04-04T11:02:05.998Z","avatar_url":"https://github.com/jr-cologne.png","language":"PHP","readme":"# Login Script\n\nA simple object-oriented and database-based login script with PHP.\n\n## Requirements/Dependencies\n\n- [PHP](http://php.net) (version 7.0 or higher)\n- Database, which supports PDO (e.g. MySQL)\n- [jr-cologne/db-class](https://github.com/jr-cologne/db-class) (version ^2.1)\n- [Google APIs Client Library for PHP](https://github.com/google/google-api-php-client) (version ^2.2)\n- [Codebird Twitter API Library](https://github.com/jublonet/codebird-php) (version ^3.1)\n- [Bugsnag PHP Library](https://github.com/bugsnag/bugsnag-php) (version ^3.14)\n- [SwiftMailer](https://github.com/swiftmailer/swiftmailer) (version ^6.1)\n- [Bootstrap](https://getbootstrap.com/) (version ^4.1.3)\n\n## Installation\n\n### Using Composer (recommended)\n\nUsing Composer is the quickest way to install everything. For this, make sure you have [Composer](https://getcomposer.org) installed.\n\nNow, in order to run the login-script on your local machine or your own server, follow these installation instructions:\n\nFirst of all, execute this command in your terminal or command prompt:\n\n```\ncomposer create-project jr-cologne/login-script your-project-name\n```\n\nDo not forget to change `your-project-name` to your specific name for your project folder.\n\nThe command `composer create-project` is basically the same as doing a `git clone` followed by a `composer install`.\n\nThis means that you are almost finished already. Executing the one command above should have downloaded the entire project and installed all Composer dependencies as well.\n\nNow, just continue with the [Installation of Dependencies](https://github.com/jr-cologne/login-script#installation_of_dependencies), but keep in mind that you can skip the part with Composer. Just move on to npm.\n\n### Manual Installation\n\nIn order to run the login-script on your local machine or your own server, follow these installation instructions:\n\n1. Download one of the archive files from the latest (stable) release of this project, either *zip* or *tar.gz*.\n2. Unpack the archive of your choice and put the files into a folder where you project should be located.\n3. Install dependencies, see [Installation of Dependencies](https://github.com/jr-cologne/login-script#installation_of_dependencies) for more details.\n\n## Installation of Dependencies\n\nYou have got two options to install all dependencies for this project:\n\n### Using Composer \u0026 npm (recommended)\n\nFirst of all, make sure you have [Composer](https://getcomposer.org) installed. Then execute this command in your terminal or command prompt:\n\n```\ncomposer install\n```\n\nThis should install all dependencies listed in the file `composer.json`.\n\nSecondly, you also need to have [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/) installed on your computer.\n\nThen, go ahead and run the following command:\n\n```\nnpm install\n```\n\n### Manual Installation\n\nThe second option to install all dependencies is just doing it manually.\n\nFor this, download all dependencies from their repositories linked above and organize them into some kind of \"vendor\" folder.\n\nThen, open up the file `app/init.php` and replace the line regarding the Composer autoloader with the various includes for all dependencies.\n\n## Getting Started\n\nBefore following this short Getting Started Guide, please ensure that you have successfully installed everything outlined in the above Installation Guide.\n\nIn order to achieve getting the login-script working as expected, you need to do the following things:\n\n- Set up your database and the connection to it\n- Set up your access to the API of Google and Twitter for the Social Authentication feature as well as Bugsnag for Error Handling\n- Set up the connection to an SMTP server for Email Delivery\n- Deploy!\n\nLet's get started!\n\n### Database Setup\n\nIf you take a look in the `database` folder, you can see that the login-script provides you with a SQL file (`db-setup.sql`) for setting up your database. Just load this into your database client and everything should be fine.\n\nAfter you have successfully set up the database, you only need to establish your database connection.\n\nFor this, copy the file `.env.example` and rename it to `.env`.\n\nFor now, you just need to worry about changing the following settings inside the environment variables file:\n\n```\nDATABASE_TYPE=mysql\nDATABASE_NAME=login-script\nDATABASE_HOST=127.0.0.1\nDATABASE_USER=user\nDATABASE_PASSWORD=password\n```\n\nThat's it. Your database should now be ready to go.\n\n### Setting up Access to APIs for Social Auth and Error Handling\n\nAs I already mentioned shortly, you need access to a total of three APIs in order to make everything work properly without really touching any code.\n\nThese are the three APIs/Services of interest:\n\n- [Bugsnag](https://www.bugsnag.com/)\n- [Google Sign-In for Websites](https://developers.google.com/identity/sign-in/web/)\n- [Twitter API](https://developer.twitter.com/)\n\nLet's start setting them up.\n\n#### Bugsnag\n\nFirst of all, go ahead and sign up for a Bugsnag account at [bugsnag.com](https://app.bugsnag.com/user/new/).\n\nAfter that, Bugsnag will guide you through a small setup tour for your specific project.\n\nIn the case of the login-script, you need to select a server application, the language PHP and no framework (other) when you are asked for this kind of information.\n\nOnce you successfully set up your project, a quick installation guide is shown. In there, you can also find your API key.\nIn our case, you can find this API key inside the line of code which basically looks like that:\n\n```php\n$bugsnag = Bugsnag\\Client::make('your-api-key');\n```\n\nNow, just copy that API key. In case you are not working with environment variables to store secret information like API credentials, the login-script supports grabbing your API key from a JSON config file. For Bugsnag, this config file should look like this:\n\n```json\n{\n  \"api_key\": \"your-api-key\"\n}\n```\n\nSo, just paste your API key from Bugsnag in there and then save your JSON file to some directory which is ignored by git since you don't want your API keys to be publically available on GitHub or something like that.\n\nFinally, to make sure the login-script knows where it can find your file, you need to specify the file path inside `.env`.\n\nInside the file `.env`, look for something looking like this and modify it for your own needs:\n\n```\nBUGSNAG_CONFIG_FILE=storage/error_handling/bugsnag/bugsnag-api-credentials.json\n```\n\nThat's all. You should now be ready for handling your errors with Bugsnag.\n\n#### Google Sign-In for Websites\n\nSetting up Google Sign-In for Websites is relatively simple since Google provides you with a tone of information and an easy setup tour.\n\nJust go to the [Getting Started Guide for Google-Sign for Websites](https://developers.google.com/identity/sign-in/web/sign-in) and click on the button \"Configure a Project\".\n\nYou are then asked to enter a project and a product name. Next, you need to configure your OAuth client.\n\nFor your application environment, choose \"Web Server\". Furthermore, your authorized Redirect URIs need to look similar to this:\n\n```\nhttp://example.com/google_login.php\nhttp://example.com/google_register.php\n\nFor Localhost:\nhttp://localhost/google_login.php\nhttp://localhost/google_register.php\n```\n\nVery important is that the filenames stay the same. The rest can be adapted.\n\nNext, download the client configuration of your created project. This is a JSON file which can be used for the login-script to define your credentials for the Google API. For this, again just use a directory which is ignored by git and make sure you put the file path inside the `.env` file of the login-script. This is the setting you need to change:\n\n```\nGOOGLE_CONFIG_FILE=storage/social_auth/google/xxx.apps.googleusercontent.com.json\nGOOGLE_REDIRECT_URI_LOGIN=http://example.com/google_login.php\nGOOGLE_REDIRECT_URI_REGISTER=http://example.com/google_register.php\n```\n\nThe path to your Google client configuration file needs to be specified at `GOOGLE_CONFIG_FILE`. In addition, go ahead and change the redirect URIs as well. The rest can stay the same.\n\nThat's it. You can now move on to Twitter.\n\n#### Twitter API\n\nSetting up everything for accessing the Twitter API is a bit more complex compared to Google.\n\nFirst of all, you need to create a Twitter App over at [apps.twitter.com](https://apps.twitter.com/). In order to be able to do this, you might need to [apply for a Twitter developer account](https://developer.twitter.com/en/apply/user).\n\nDuring this process, you are asked for a project name, a description, the website of your application and a Callback URL.\n\nThis is basically the same as the Redirect URI what Google calls it. Again, this needs to look similar to this:\n\n```\nhttp://example.com/twitter_login.php\nhttp://example.com/twitter_register.php\n\nFor Localhost:\nhttp://localhost/twitter_login.php\nhttp://localhost/twitter_register.php\n```\n\nLike already mentioned, it is especially important that the filename stays the same. The rest can be edited.\n\nOnce you then successfully created your app, you need to change the following settings for your Twitter App:\n\n- Go to the settings page and activate the checkbox \"Allow this application to be used to Sign in with Twitter\".\n- Go to the permissions page. Under \"Additional Permissions\", activate the checkbox \"Request email addresses from users\".\n\nNext, go to the page \"Keys and Access Tokens\". There you can find your API key and your API secret key.\n\nNow, you need to copy and paste them into another JSON config file responsible for the Twitter API credentials.\n\nHere is the required format:\n\n```json\n{\n  \"api_key\": \"your-api-key\",\n  \"api_secret\": \"your-api-secret-key\"\n}\n```\n\nSave this file including your credentials inside a folder which is ignored by git and specify the file path inside the file `.env`.\n\n```\nTWITTER_CONFIG_FILE=storage/social_auth/twitter/twitter-api-credentials.json\nTWITTER_REDIRECT_URI_LOGIN=http://example.com/twitter_login.php\nTWITTER_REDIRECT_URI_REGISTER=http://example.com/twitter_register.php\n```\n\nLike with Google, you need to change the `TWITTER_CONFIG_FILE` option as well as the Redirect URIs.\n\nThat's all. You should now have access to the Twitter API.\n\n#### Setting up Email Delivery through an SMTP server\n\nFinally, let's set up email delivery by configuring the login-script to use an SMTP server for this.\n\nIf you don't have an SMTP server, you might be interested in using [Gmail's SMTP server](https://support.google.com/a/answer/176600?hl=en).\n\nOnce you have the credentials to some kind of SMTP server, go ahead and create another JSON config file inside a directory which is ignored by git. The format of your JSON file is as follows:\n\n```json\n{\n  \"smtp_server\": \"your-smtp-server-address\",\n  \"smtp_port\": \"your-smtp-port\",\n  \"smtp_encryption\": \"tls\",\n  \"smtp_username\": \"your-smtp-username\",\n  \"smtp_password\": \"your-smtp-password\"\n}\n```\n\nAfter entering your credentials, save the JSON file and then open up the `.env` file of the login-script.\n\nNow, search for this entry:\n\n```\nSMTP_CONFIG_FILE=storage/mail/smtp/smtp-server-credentials.json\n```\n\nEverything you need to specify is the file path to your file containing the SMTP server credentials.\n\nAfter doing all of this, everything should be ready to go. Go ahead, deploy your application and have fun!\nIf you want to, you can, of course, customize the login-script according to your own needs.\n\n## Contributing\n\nFeel free to contribute to this project! Any kinds of contributions are highly appreciated!\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/jr-cologne/login-script/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjr-cologne%2Flogin-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjr-cologne%2Flogin-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjr-cologne%2Flogin-script/lists"}