-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrun-examples.sh
More file actions
executable file
Β·168 lines (146 loc) Β· 4.74 KB
/
run-examples.sh
File metadata and controls
executable file
Β·168 lines (146 loc) Β· 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
# Kinde PHP SDK Examples Runner
# This script helps you run the various examples
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the right directory
if [ ! -f "composer.json" ]; then
print_error "Please run this script from the kinde-php-sdk directory"
exit 1
fi
# Function to check environment variables
check_env_vars() {
local missing_vars=()
if [ -z "$KINDE_DOMAIN" ]; then
missing_vars+=("KINDE_DOMAIN")
fi
if [ -z "$KINDE_CLIENT_ID" ]; then
missing_vars+=("KINDE_CLIENT_ID")
fi
if [ -z "$KINDE_CLIENT_SECRET" ]; then
missing_vars+=("KINDE_CLIENT_SECRET")
fi
if [ ${#missing_vars[@]} -ne 0 ]; then
print_warning "Missing environment variables: ${missing_vars[*]}"
print_status "Please set them before running examples:"
echo "export KINDE_DOMAIN=\"https://your-domain.kinde.com\""
echo "export KINDE_CLIENT_ID=\"your_client_id\""
echo "export KINDE_CLIENT_SECRET=\"your_client_secret\""
echo ""
return 1
fi
return 0
}
# Function to run management client example
run_management_example() {
print_status "Running Management Client Example..."
if ! check_env_vars; then
print_error "Cannot run management example without environment variables"
return 1
fi
if php examples/management_client_example.php; then
print_success "Management client example completed"
else
print_error "Management client example failed"
return 1
fi
}
# Function to show framework examples info
show_framework_info() {
print_status "Framework Examples Available:"
echo " π Laravel: examples/laravel/ExampleController.php"
echo " π Slim: examples/slim/ExampleApp.php"
echo " π Symfony: examples/symfony/ExampleController.php"
echo " π CodeIgniter: examples/codeigniter/ExampleController.php"
echo ""
print_status "To use framework examples:"
echo " 1. Copy the example files to your framework application"
echo " 2. Install the Kinde SDK: composer require kinde/kinde-php-sdk"
echo " 3. Set up routes and environment variables"
echo " 4. Test the authentication endpoints"
}
# Function to show help
show_help() {
echo "Kinde PHP SDK Examples Runner"
echo ""
echo "Usage: $0 [OPTION]"
echo ""
echo "Options:"
echo " management Run the management client example (requires env vars)"
echo " frameworks Show information about framework examples"
echo " setup Show setup instructions"
echo " help Show this help message"
echo ""
echo "Examples:"
echo " $0 management # Run management client example"
echo " $0 frameworks # Show framework examples info"
echo " $0 setup # Show setup instructions"
}
# Function to show setup instructions
show_setup() {
echo "Kinde PHP SDK Examples Setup"
echo "============================"
echo ""
echo "1. Install Dependencies:"
echo " composer install"
echo ""
echo "2. Set Environment Variables:"
echo " export KINDE_DOMAIN=\"https://your-domain.kinde.com\""
echo " export KINDE_CLIENT_ID=\"your_client_id\""
echo " export KINDE_CLIENT_SECRET=\"your_client_secret\""
echo " export KINDE_REDIRECT_URI=\"http://localhost:8000/auth/callback\""
echo " export KINDE_GRANT_TYPE=\"authorization_code\""
echo " export KINDE_LOGOUT_REDIRECT_URI=\"http://localhost:8000\""
echo " export KINDE_SCOPES=\"openid profile email offline\""
echo " export KINDE_PROTOCOL=\"https\""
echo ""
echo "3. Run Examples:"
echo " $0 management # Run management client example"
echo " $0 frameworks # View framework examples"
echo ""
echo "4. Framework Integration:"
echo " - Copy example files to your framework application"
echo " - Set up routes and middleware"
echo " - Test authentication flows"
echo ""
echo "For detailed instructions, see: examples/README.md"
}
# Main script logic
case "${1:-help}" in
"management")
run_management_example
;;
"frameworks")
show_framework_info
;;
"setup")
show_setup
;;
"help"|"-h"|"--help")
show_help
;;
*)
print_error "Unknown option: $1"
show_help
exit 1
;;
esac
print_success "Examples runner completed!"